-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add GeoJSON overlays #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jkasprzyk17
wants to merge
5
commits into
main
Choose a base branch
from
feat/geojson-overlay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cb90f8e
feat: add GeoJSON overlays
jkasprzyk17 65758b5
fix: apply GeoJSON opacity to fallback colors
jkasprzyk17 9a8506c
fix: preserve GeoJSON polygon holes
jkasprzyk17 d9e9830
fix: validate FeatureCollection bounding boxes
jkasprzyk17 40042b3
fix: support GeoJSON marker color and z-index
jkasprzyk17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # GeoJSON overlays | ||
|
|
||
| `Geojson` renders a GeoJSON object as existing map overlays. Conversion happens in JavaScript and reuses the marker, polyline, and polygon descriptor pipeline on iOS and Android. | ||
|
|
||
| ## Supported geometry | ||
|
|
||
| | GeoJSON type | Overlay | | ||
| | -------------------- | ----------------------------- | | ||
| | `Point` | `Marker` | | ||
| | `MultiPoint` | One `Marker` per position | | ||
| | `LineString` | `Polyline` | | ||
| | `MultiLineString` | One `Polyline` per line | | ||
| | `Polygon` | `Polygon` with interior holes | | ||
| | `MultiPolygon` | One `Polygon` per part | | ||
| | `Feature` | Inner geometry | | ||
| | `FeatureCollection` | Each feature | | ||
| | `GeometryCollection` | Each nested geometry | | ||
|
|
||
| Coordinates are `[longitude, latitude]`. A third value (altitude) is ignored. | ||
|
|
||
| ## Style | ||
|
|
||
| Component props supply defaults. Feature `properties` override them using simplestyle names: | ||
|
|
||
| | Property | Applies to | Notes | | ||
| | ---------------- | ------------- | ------------------------------ | | ||
| | `stroke` | Line, polygon | Hex color | | ||
| | `stroke-width` | Line, polygon | Density-independent pixels | | ||
| | `stroke-opacity` | Line, polygon | Replaces alpha on hex `stroke` | | ||
| | `fill` | Polygon | Hex color | | ||
| | `fill-opacity` | Polygon | Replaces alpha on hex `fill` | | ||
| | `marker-color` | Point | Default marker color | | ||
| | `title` / `name` | Point | Marker title | | ||
| | `zIndex` | All overlays | Drawing order | | ||
|
|
||
| Colors follow the library-wide format: `#RGB`, `#RGBA`, `#RRGGBB`, or `#RRGGBBAA` with alpha last. Opacity properties replace the color's alpha, so `fill: '#34C75980'` with `fill-opacity: 0.25` becomes `#34C75940`. Non-hex colors are left unchanged. | ||
|
|
||
| Component-level `markerColor` and `zIndex` provide defaults. Feature properties take precedence. `zIndex` applies to every generated Google Maps overlay and to Apple Maps markers; MapKit does not expose shape overlay z-ordering. | ||
|
|
||
| `onPress` receives the original `GeojsonFeature`, including `properties`. | ||
|
|
||
| ## Limits | ||
|
|
||
| - Prefer `geojsonToOverlayDescriptors` plus bulk `MapView` overlay props above about 1000 generated overlays. | ||
| - Point styling supports title text and default marker color; custom marker views are not applied. | ||
| - TopoJSON is not parsed. Convert it to GeoJSON first. | ||
| - Invalid GeoJSON does not throw. It is skipped with a development warning. | ||
|
|
||
| ## Bulk conversion | ||
|
|
||
| ```tsx | ||
| import { MapView, geojsonToOverlayDescriptors } from 'react-native-better-maps'; | ||
|
|
||
| const overlays = geojsonToOverlayDescriptors(deliveryZones, { | ||
| strokeColor: '#FF3B30', | ||
| fillColor: '#FF3B3044', | ||
| strokeWidth: 2, | ||
| }); | ||
|
|
||
| export function DeliveryZonesMap() { | ||
| return ( | ||
| <MapView | ||
| markers={overlays.markers} | ||
| polylines={overlays.polylines} | ||
| polygons={overlays.polygons} | ||
| onPolygonPress={(id) => { | ||
| console.log(overlays.featuresByOverlayId[id]?.properties); | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Qualify the
zIndexdocumentation by platform.properties.zIndexdoes not always override drawing order.docs/geojson.mdLine 38 states that MapKit does not expose shape overlay z-ordering. Update this sentence to qualify Apple polygon and polyline behavior. The current wording overpromises the result for those overlays.🤖 Prompt for AI Agents