Working with GeoJSON Data

This SDK offers several ways to work with GeoJSON files.
GeoJSON is a standard file format for representing geographic data.

Adding a GeoJSON file to the map

You can use
Mapbox Studio’s Datasets editor to
upload a GeoJSON file and include it in your custom map style. The GeoJSON data
will be hosted on Mapbox servers. When a user loads your style, the SDK
automatically loads the GeoJSON data for display.

About GeoJSON deserialization

The process of converting GeoJSON text into MGLShape, MGLFeature, or
MGLShapeCollectionFeature objects is known as “GeoJSON deserialization”.
GeoJSON geometries, features, and feature collections are known in this SDK as
shapes, features, and shape collection features, respectively.

Each GeoJSON object type corresponds to a type provided by either this SDK or
the Core Location framework:

A Feature object in GeoJSON corresponds to an instance of an MGLShape
subclass conforming to the MGLFeature protocol. There is a distinct
MGLFeature-conforming class for each type of geometry that a GeoJSON feature
can contain. This allows features to be used as raw shapes where convenient. For
example, some features can be added to a map view as annotations. Note that
identifiers and attributes will not be available for feature querying when a
feature is used as an annotation.

In contrast to the GeoJSON standard, it is possible for MGLShape subclasses
other than MGLPointAnnotation to straddle the antimeridian.

The following GeoJSON data types correspond straightforwardly to Foundation data
types when they occur as feature identifiers or property values: