Skip to content

Add support for geogrid-maplibre-gl plugin#99

Merged
giswqs merged 2 commits intomainfrom
claude/add-geogrid-support-011CUSsGhHi8LR9j4Q1f4JGD
Oct 25, 2025
Merged

Add support for geogrid-maplibre-gl plugin#99
giswqs merged 2 commits intomainfrom
claude/add-geogrid-support-011CUSsGhHi8LR9j4Q1f4JGD

Conversation

@giswqs
Copy link
Copy Markdown
Member

@giswqs giswqs commented Oct 25, 2025

image

claude and others added 2 commits October 24, 2025 23:17
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>
Copilot AI review requested due to automatic review settings October 25, 2025 02:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_control and remove_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.

Comment on lines +3449 to +3480
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;
}
Copy link

Copilot AI Oct 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

@github-actions github-actions Bot temporarily deployed to pull request October 25, 2025 02:57 Inactive
@giswqs giswqs merged commit 647de48 into main Oct 25, 2025
8 checks passed
@giswqs giswqs deleted the claude/add-geogrid-support-011CUSsGhHi8LR9j4Q1f4JGD branch October 25, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants