Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

simplemap

Python module to allow for easy creation of a google maps HTML file.

Subscribe to updates I use simplemap


Statistics on simplemap

Number of watchers on Github 113
Number of open issues 2
Average time to close an issue 6 days
Main language Python
Average time to merge a PR about 1 month
Open pull requests 2+
Closed pull requests 2+
Last commit over 2 years ago
Repo Created over 3 years ago
Repo Last Updated over 1 year ago
Size 17 KB
Organization / Authorpatrick--
Contributors1
Page Updated
Do you use simplemap? Leave a review!
View open issues (2)
View simplemap activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating simplemap for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

simplemap

Example

Overview

This Python library allows you to plot GPS coordinates on a standalone google map contained in an HTML file. Functionality is focused around mapping of points, so other google maps API features will not be implemented (i.e. directions, reverse geocoding, etc).

My plans for features to be implemented in the mediate future are:

  • Google map interface event callbacks
  • Custom marker labels
  • Custom marker text
  • Customer marker images

=======

Installation

Installation is very straightforward. Simply clone the repository and install the necessary requirements

git clone https://github.com/patrick--/simplemap/
cd simplemap
pip install -r requirements.txt

=========

Prerequisites

Before using this library you will need to obtain a Google Maps Javascript API key. The following link has instructions on getting a key

Once you get a key, make sure to put it in the config.json file. Any problems with API authentication will result in an error popup in your output.html file.

API Error Example

=======

Usage

First, import the simplemap library

import simplemap

Next, initialize your map object: simplemap.Map().

Parameters:
  • title - The title of the HTML map webpage
  • center - list of lat/lon values for map center. Default value of None auto centers map - Optional
  • zoom - Zoom level of the map, defaults to 11 - Optional
  • markers - list of markers, where a marker is a list: optional hovertext, lat and lon - Optional
  • html_template - HTML template used to generate a map. Currently the default value of basic.html is the only option - Optional
  • config_file - JSON file containing the google maps api_key, defaults to config.json - Optional

Note: By default the map will automatically center and zoom based on points given. For a custom center point, make sure to give center a lat/lon value.

Finally, write the map to an HTML file: Map.write()

Parameters:
  • output_file_name - Filename that HTML will be written to

Examples

In this first example, notice that zoom and center were not given values. This allows the map to center and zoom itself based on the points provided.

import simplemap

map_title = 'Example Map'
gps_markers = [ ['Example text', 34.4563,-118.1241], [34.6432,-118.1554] ]

example_map = simplemap.Map(map_title, markers=gps_markers)
example_map.write('example.html')

This example demonstrates that markers is a property of the Map() class - so it can be given a value after initialization.

import simplemap

example_map = simplemap.Map('Test Title', [34.5124, -118.1111])
example_map.markers = [ ['Example text', 34.4563,-118.1241], [34.6432,-118.1554] ]
example_map.write('example.html')

Finally, this example demonstrates custom values given to both center and zoom.

import simplemap

map_title = 'Example Map'
center_point  = [34.5124, -118.1111]
zoom_level = 5
gps_markers = [ ['Example text', 34.4563,-118.1241], [34.6432,-118.1554] ]

example_map = simplemap.Map(map_title, center=center_point, zoom=zoom_level, markers=gps_markers)
example_map.write('example.html')

========

simplemap open issues Ask a question     (View All Issues)
  • over 3 years Is there a port of this to python3?
  • over 3 years Map file will be blank if an empty coordinate is passed as a marker
simplemap open pull requests (View All Pulls)
  • webbrowser.open(file_url)
  • Added line functionality between markers/waypoints on map.
simplemap list of languages used
Other projects in Python