You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
MGLGeoJSONSource should have a features initializer #6302
featureiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in generalruntime styling
MGLGeoJSONSource currently has four initializers: two that accept a GeoJSON-formatted NSData object, and two that accept a URL to a local or remote GeoJSON file. MGLGeoJSONSource should have an additional initializer that accepts an array of MGLFeatures and would accompany the existing read-only features property.
Consider this basic use case: the developer wants to create a GeoJSON source containing a particular polyline feature. Currently, they have to either compose a GeoJSON string and stuff it into an NSData object or write out a GeoJSON file and refer to it by its path. Instead, it would be much more convenient to create the source using an MGLPolyline object directly.
To simplify MGLGeoJSONSource, we should remove -initWithSourceIdentifier:geoJSONData: and -initWithSourceIdentifier:URL: and make the options parameter on the remaining initializers nullable. MGLGeoJSONSource would be left with three initializers corresponding to the three properties features, geoJSONData, and URL.
We should also make MGLFeature.attributes read-write so that it’s possible to create a feature with specific attributes that a layer might filter for.
This will require functionality for writing out MGLFeature objects as mapbox::geojson types or, alternatively, as GeoJSON strings. Each of the MGLFeature subclasses would implement a -geoJSONFeature method similar to the existing -annotationObjectWithDelegate: method, but using the attributes dictionary instead of MGLMultiPointDelegate.
In order to convert the attribute dictionary into a mapbox::geojson::property_map, we can implement category methods similar to -[NSNumber(MGLStyleAttributeAdditions) mbgl_boolPropertyValue]. Or, if that proves to be too cumbersome, a single recursive method would also work.
This will require functionality for writing out MGLFeature objects as mapbox::geojson types
The manual MGLFeature-to-GeoJSON conversion in nitaliano/react-native-mapbox-gl#419 could serve as a template for the kind of transformation we’d need to do here.
featureiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in generalruntime styling
Activity
1ec5 commentedon Sep 9, 2016
This will require functionality for writing out MGLFeature objects as
mapbox::geojsontypes or, alternatively, as GeoJSON strings. Each of the MGLFeature subclasses would implement a-geoJSONFeaturemethod similar to the existing-annotationObjectWithDelegate:method, but using theattributesdictionary instead of MGLMultiPointDelegate.In order to convert the attribute dictionary into a
mapbox::geojson::property_map, we can implement category methods similar to-[NSNumber(MGLStyleAttributeAdditions) mbgl_boolPropertyValue]. Or, if that proves to be too cumbersome, a single recursive method would also work.1ec5 commentedon Sep 26, 2016
The manual MGLFeature-to-GeoJSON conversion in nitaliano/react-native-mapbox-gl#419 could serve as a template for the kind of transformation we’d need to do here.
Refactored MGLGeoJSONSource to 3 initializers as explained in issue #…