Handle geojson layers like other layers#605
Merged
digitaltom merged 31 commits intomainfrom Feb 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors MapLibre layer handling so GeoJSON layers are treated similarly to other layer types (separate sources/styles per layer) and introduces layer-level flags intended to control clustering/heatmap behavior.
Changes:
- Introduces per-layer GeoJSON sources (
<type>-source-<layerId>) and new feature lookup helpers inmaplibre/layers/layers.js. - Updates various MapLibre modules/controllers to use the new feature lookup approach instead of
geojsonData. - Adds a Wikipedia marker icon and extends
Layersummaries withheatmap/clusterflags.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| public/icons/wikipedia.png | Adds an icon used by the Wikipedia layer features. |
| app/models/layer.rb | Adds heatmap/cluster fields and includes them in serialized layer summaries. |
| app/javascript/maplibre/undo.js | Starts migration away from geojsonData imports (but still needs further refactor). |
| app/javascript/maplibre/styles.js | Updates style initialization and heatmap layer handling; switches feature lookup to getFeature. |
| app/javascript/maplibre/routing/osrm.js | Switches route feature lookup to getFeature. |
| app/javascript/maplibre/map.js | Removes global geojsonData usage patterns and shifts rendering toward per-layer sources. |
| app/javascript/maplibre/layers/layers.js | Initializes per-layer GeoJSON sources/styles and adds getFeature/getFeatures/hasFeatures. |
| app/javascript/maplibre/feature.js | Uses new feature access helpers for edit gating and derived-feature generation inputs. |
| app/javascript/maplibre/edit.js | Uses new helpers for “untouched map” logic and URL-based selection. |
| app/javascript/maplibre/controls/shared.js | Updates feature list items to reference the new per-layer source names. |
| app/javascript/controllers/feature/modal_controller.js | Refactors selected-feature access (now needs getFeature import). |
| app/javascript/controllers/feature/edit_controller.js | Refactors edit-feature access (now needs getFeature import). |
Comments suppressed due to low confidence (1)
app/javascript/maplibre/map.js:123
initializeMaphighlights a URL-selected feature viahighlightFeature(feature, true)without passing the feature’s source. Since the default source inhighlightFeatureisgeojson-source(which is no longer created),setFeatureStatewill fail or highlight the wrong source. Determine the correct source for the feature (e.g., from the owning layer) and pass it explicitly.
const urlFeatureId = new URLSearchParams(window.location.search).get('f')
let feature = getFeature(urlFeatureId)
if (feature) {
resetControls()
highlightFeature(feature, true)
const center = centroid(feature)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Pull Request Test Coverage Report for Build 21788627754Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
| addRedoState(prevState.type, geojsonData.features[idx], false) | ||
| let feature = getFeature(prevState.state.id, 'geojson') | ||
| if (feature) { | ||
| addRedoState(prevState.type, feature, false) |
| addRedoState(prevState.type, geojsonData.features[idx], false) | ||
| let feature = getFeature(prevState.state.id, 'geojson') | ||
| if (feature) { | ||
| addRedoState(prevState.type, feature, false) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.