{"id":9017,"library":"gmplot","title":"gmplot","description":"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.","status":"active","version":"1.4.1","language":"en","source_language":"en","source_url":"https://github.com/gmplot/gmplot","tags":["mapping","geospatial","google maps","plotting","visualization"],"install":[{"cmd":"pip install gmplot","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"The primary class to interact with is GoogleMapPlotter, not the module itself.","wrong":"import gmplot; gmap = gmplot()","symbol":"GoogleMapPlotter","correct":"from gmplot import GoogleMapPlotter"},{"note":"Importing the top-level module is common, but accessing internal objects like `gmplot.GoogleMapPlotter` is standard.","wrong":"from gmplot import gmplot","symbol":"gmplot","correct":"import gmplot"}],"quickstart":{"code":"import gmplot\nimport os\n\n# Replace with your actual coordinates and zoom level\nlatitude, longitude, zoom = 37.4239163, -122.0946215, 16\n\n# Initialize GoogleMapPlotter with center latitude, longitude, and zoom\n# Add your Google Maps API key using os.environ.get('GOOGLE_API_KEY', '')\n# to avoid the 'For Development Purposes Only' watermark\ngmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom, apikey=os.environ.get('GOOGLE_API_KEY', ''))\n\n# Add a marker\ngmap.marker(latitude, longitude, 'cornflowerblue', size=40, title=\"My Location\")\n\n# Add a scatter plot (e.g., nearby points)\nmore_lats = [37.425, 37.420]\nmore_lngs = [-122.090, -122.100]\ngmap.scatter(more_lats, more_lngs, '#FF0000', size=20, marker=False)\n\n# Draw the map to an HTML file\noutput_html_file = 'mymap.html'\ngmap.draw(output_html_file)\n\nprint(f\"Map saved to {output_html_file}\")","lang":"python","description":"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."},"warnings":[{"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')`).","message":"Using Google Maps without an API key will result in a 'For Development Purposes Only' watermark on your generated maps.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `gmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom)` to create a map object after `import gmplot`.","message":"The `GoogleMapPlotter` class must be instantiated as `gmplot.GoogleMapPlotter(...)`. Trying to call `gmplot()` directly will result in a `TypeError: 'module' object is not callable`.","severity":"gotcha","affected_versions":"All versions"},{"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'`).","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Use `gmap.plot(lats, lons, ...)` for routes or lines. Use `gmap.polygon(lats, lons, ...)` for filled areas.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your project runs on Python 3.5 or newer. If you encounter issues on older Python 2 versions, upgrade your Python environment.","message":"Python 2 support has been dropped. gmplot is primarily designed and tested for Python 3 environments.","severity":"deprecated","affected_versions":"<=1.3.0 (best practice to use Python 3.x)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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)`.","cause":"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.","error":"AttributeError: module 'gmplot' has no attribute 'GoogleMapPlotter'"},{"fix":"The correct way to create a map object is `gmap = gmplot.GoogleMapPlotter(latitude, longitude, zoom_level)`.","cause":"Attempting to call the `gmplot` module directly as a constructor, instead of using the `GoogleMapPlotter` class within it.","error":"TypeError: 'module' object is not callable"},{"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')`.","cause":"A Google Maps API key is required for production use and to remove the watermark, but it has not been provided or is invalid.","error":"Map displays 'For Development Purposes Only' watermark"},{"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.","cause":"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.","error":"TypeError: argument of type 'float' is not iterable (when using scatter with size/color)"}]}