Registry / data / gmplot

gmplot

JSON →
library1.4.1pypypi✓ verified 85d ago

gmplot is a Python library providing a matplotlib-like interface to plot geographical data on Google Maps. It allows users to easily add markers, heatmaps, polygons, and other visualizations to generate interactive HTML maps. The library is actively maintained; its current version, 1.4.1, includes features like draggable markers and ground overlays.

pip install gmplot
INSTALL
IMPORT
SIG · GMPLOT
G
gmplot
datapythonv1.4.1
Install
2.1s avg
Import
612ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.648s · 22MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.1s · import 0.576s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GoogleMapPlotter
from gmplot import GoogleMapPlotter
import gmplot; gmap = gmplot()
The primary class to interact with is GoogleMapPlotter, not the module itself.
gmplot
import gmplot
from gmplot import gmplot
Importing the top-level module is common, but accessing internal objects like `gmplot.GoogleMapPlotter` is standard.

This quickstart demonstrates how to create a basic Google Map, add a marker, scatter a few points, and save the result as an interactive HTML file. It highlights the use of `GoogleMapPlotter` and the importance of including an API key for full functionality. The generated HTML file can be opened in a web browser to view the map.

import gmplot import os # Replace with your actual coordinates and zoom level latitude, longitude, zoom = 37.4239163, -122.0946215, 16 # Initialize GoogleMapPlotter with center latitude, longitude, and zoom # Add your Google Maps API key using os.environ.get('GOOGLE_API_KEY', '') # to avoid the 'For Development Purposes Only' watermark gmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom, apikey=os.environ.get('GOOGLE_API_KEY', '')) # Add a marker gmap.marker(latitude, longitude, 'cornflowerblue', size=40, title="My Location") # Add a scatter plot (e.g., nearby points) more_lats = [37.425, 37.420] more_lngs = [-122.090, -122.100] gmap.scatter(more_lats, more_lngs, '#FF0000', size=20, marker=False) # Draw the map to an HTML file output_html_file = 'mymap.html' gmap.draw(output_html_file) print(f"Map saved to {output_html_file}")
Debug
Known issues
gotchaUsing Google Maps without an API key will result in a 'For Development Purposes Only' watermark on your generated maps.
fix
Obtain a Google Maps API key from the Google Cloud Console and pass it to the `GoogleMapPlotter` constructor using the `apikey` parameter (e.g., `gmap = GoogleMapPlotter(..., apikey='YOUR_API_KEY')`).
affects: All versions
gotchaThe `GoogleMapPlotter` class must be instantiated as `gmplot.GoogleMapPlotter(...)`. Trying to call `gmplot()` directly will result in a `TypeError: 'module' object is not callable`.
fix
Always use `gmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom)` to create a map object after `import gmplot`.
affects: All versions
gotchaWhen using `scatter()` or other plotting methods, ensure that iterable arguments like `color`, `size`, or `marker` match the length of `latitudes` and `longitudes`, or provide a single value to apply uniformly.
fix
If plotting multiple points with different styles, provide lists of equal length for style parameters (e.g., `color=['red', 'blue']` for two points). If a single style is desired for all points, pass a single value (e.g., `color='red'`).
affects: All versions
gotchaThe `plot()` method is used for drawing lines or paths, while `polygon()` is used for drawing filled, closed shapes. Misusing them can lead to unexpected visual output.
fix
Use `gmap.plot(lats, lons, ...)` for routes or lines. Use `gmap.polygon(lats, lons, ...)` for filled areas.
affects: All versions
deprecatedPython 2 support has been dropped. gmplot is primarily designed and tested for Python 3 environments.
fix
Ensure your project runs on Python 3.5 or newer. If you encounter issues on older Python 2 versions, upgrade your Python environment.
affects: <=1.3.0 (best practice to use Python 3.x)
Errors
Common errors & fixes
AttributeError: module 'gmplot' has no attribute 'GoogleMapPlotter'
This usually indicates an outdated `gmplot` installation, a local file named `gmplot.py` shadowing the actual library, or an incorrect import where `gmplot` is treated as the class itself.
fix
1. Ensure you have the latest `gmplot`: `pip install --upgrade gmplot`. 2. Check if there's a file named `gmplot.py` in your working directory and rename it. 3. Correct the import and instantiation to `import gmplot; gmap = gmplot.GoogleMapPlotter(lat, lon, zoom)`.
TypeError: 'module' object is not callable
Attempting to call the `gmplot` module directly as a constructor, instead of using the `GoogleMapPlotter` class within it.
fix
The correct way to create a map object is `gmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom_level)`.
Map displays 'For Development Purposes Only' watermark
A Google Maps API key is required for production use and to remove the watermark, but it has not been provided or is invalid.
fix
Obtain a valid Google Maps API key from the Google Cloud Console and pass it as the `apikey` parameter during `GoogleMapPlotter` instantiation: `gmap = gmplot.GoogleMapPlotter(..., apikey='YOUR_API_KEY')`.
TypeError: argument of type 'float' is not iterable (when using scatter with size/color)
The `size` or `color` parameter in `scatter()` was passed an iterable (e.g., a tuple or list) when the method expected a single float for `size` or a single string for `color` to apply uniformly, or vice-versa.
fix
If you want a uniform style, pass a single value (e.g., `size=40`, `color='red'`). If you want different styles per point, ensure the list of styles has the same length as your latitude/longitude lists and that the type for each element matches the expected parameter type (e.g., `size=[20, 30, 40]`). Alternatively, loop and plot each point individually if complex individual styling is needed.
Upgrade
Version history
1.4.1latest on PyPI · released Jun 26, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
41 hits · last 30 days
node
36
OpenAI (training)
1
Resources