Add support for geogrid-maplibre-gl plugin#99
Conversation
giswqs
commented
Oct 25, 2025
This commit adds support for the geogrid-maplibre-gl plugin, which displays a customizable geographic grid (graticule) with labeled coordinates on MapLibre maps. Changes: - Add add_geogrid_control() and remove_geogrid_control() methods to MapLibreMap class - Support customizable grid and label styling options - Add zoom level range control for grid visibility - Implement ES module loading for GeoGrid plugin in JavaScript - Add comprehensive notebook example demonstrating GeoGrid usage - Include examples of custom styling, zoom ranges, and integration with other controls The GeoGrid plugin supports: - Custom line colors, widths, and dash patterns - Customizable label styling (color, size, shadow) - Zoom-dependent visibility - Globe projection (MapLibre GL 5.x) - Layer ordering control 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for the geogrid-maplibre-gl plugin, enabling geographic grid (graticule) overlays with labeled coordinates on MapLibre maps. The implementation includes dynamic plugin loading, style mapping between MapLibre and GeoGrid formats, and comprehensive example documentation.
Key Changes:
- Added Python API methods (
add_geogrid_controlandremove_geogrid_control) for managing grid overlays - Implemented JavaScript plugin loader and style property mapper to handle different module export formats
- Created comprehensive Jupyter notebook demonstrating grid customization, zoom-level control, and globe projection support
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| anymap/maplibre.py | Adds Python methods for adding/removing GeoGrid control with style configuration |
| anymap/static/maplibre_widget.js | Implements GeoGrid plugin loading, style mapping, and control lifecycle management |
| docs/examples/geogrid_example.ipynb | Provides example notebook demonstrating various GeoGrid usage patterns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case 'geogrid': { | ||
| const GeoGridClass = resolveGeoGridClass(); | ||
| if (!GeoGridClass) { | ||
| console.warn('GeoGrid plugin not available during restore'); | ||
| return; | ||
| } | ||
| // Remove position from options as GeoGrid doesn't use it | ||
| const { position: _, gridStyle, labelStyle, ...otherConfig } = controlOptions || {}; | ||
|
|
||
| // Map MapLibre paint properties to GeoGrid style properties | ||
| const geogridOptions = { | ||
| map, | ||
| ...otherConfig, | ||
| ...(gridStyle && { gridStyle: mapToGeoGridStyle(gridStyle) }), | ||
| ...(labelStyle && { labelStyle: mapToGeoGridStyle(labelStyle) }) | ||
| }; | ||
|
|
||
| try { | ||
| const geogridInstance = new GeoGridClass(geogridOptions); | ||
|
|
||
| // Explicitly call add() to render the grid on the map | ||
| if (typeof geogridInstance.add === 'function') { | ||
| geogridInstance.add(); | ||
| } | ||
|
|
||
| el._geogridInstance = geogridInstance; | ||
| el._controls.set(controlKey, { type: 'geogrid', instance: geogridInstance }); | ||
| } catch (error) { | ||
| console.error('Failed to restore GeoGrid instance:', error); | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
This code block (lines 3449-3480) is duplicated almost identically at lines 4219-4250. Consider extracting this logic into a shared helper function to reduce duplication and improve maintainability.
|
🚀 Deployed on https://68fc3ca5366de661b409ee2f--opengeos.netlify.app |