Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MGLGeoJSONSource should have a features initializer #6302

Closed

Description

@1ec5

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.

/cc @boundsj @incanus @frederoni

Activity

  1. added
    iOS
    macOS
    on Sep 9, 2016
  2. added this to the ios-v3.4.0 milestone on Sep 9, 2016
  3. 1ec5 commented on Sep 9, 2016

    @1ec5
    ContributorAuthor

    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.

  4. self-assigned this
    on Sep 13, 2016
  5. added
    navigation
    on Sep 26, 2016
  6. 1ec5 commented on Sep 26, 2016

    @1ec5
    ContributorAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureiOSmacOSnavigationruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions