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

Add MGLShape from GeoJSON example #7627

Merged
merged 1 commit into from
Jan 9, 2017
Merged

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jan 8, 2017

Added an example of deserializing an MGLShape from a GeoJSON file.

/ref #7622 (comment)
/cc @nitrag

Added an example of deserializing an MGLShape from a GeoJSON file.
@mention-bot
Copy link

@1ec5, thanks for your PR! By analyzing this pull request, we identified @incanus to be potential reviewers.

@1ec5 1ec5 added documentation iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling labels Jan 8, 2017
@1ec5 1ec5 added this to the ios-v3.4.0 milestone Jan 8, 2017
@1ec5 1ec5 self-assigned this Jan 8, 2017
@1ec5 1ec5 requested a review from ericrwolfe January 8, 2017 05:50
Copy link
Contributor

@ericrwolfe ericrwolfe left a comment

Choose a reason for hiding this comment

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

Huh, didn't even know this was available 😃.

Is there an advantage of using MGLShape's convenience initializer over -[MGLShapeSource initWithIdentifier:URL:options:] or vise versa (other than perhaps that one can be used for MGLOverlays while the other is runtime-styling specific)?

At some point, we should define a preference and link between the two in the docs.

@1ec5
Copy link
Contributor Author

1ec5 commented Jan 9, 2017

Is there an advantage of using MGLShape's convenience initializer over -[MGLShapeSource initWithIdentifier:URL:options:] or vise versa (other than perhaps that one can be used for MGLOverlays while the other is runtime-styling specific)?

MGLShapeSource.URL is primarily useful for create a shape source with the contents of a GeoJSON file stored remotely. To be sure, you can specify a local file URL, but if you populate a shape source with a URL instead of a shape, the shape source is a black box: the only way you can access the shape data is via feature querying, which returns tiled data.

+[MGLShape shapeWithData:encoding:error:] is more versatile. You can use it to deserialize GeoJSON data, avoiding the mess of typecasts that results from NSJSONSerialization, even without using MGLMapView at all. Additionally, when you create an MGLShapeSource using a shape, such as the result of +[MGLShape shapeWithData:encoding:error:], you retain the ability to access the shape losslessly. Access to the shape can be important if, for example, you intend to read a LineString from GeoJSON at launch but continually append to the polyline at runtime.

@1ec5 1ec5 merged commit 0749659 into release-ios-v3.4.0 Jan 9, 2017
@1ec5 1ec5 deleted the 1ec5-shape-example-7622 branch January 9, 2017 19:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants