MGLFeatureprotocol is used to provide details about geographic features contained in an
MGLVectorSourceobject. Each concrete subclass of
MGLShapein turn has a subclass that conforms to this protocol. A feature object associates a shape with an optional identifier and attributes.
You can add custom data to display on the map by creating feature objects and adding them to an
-[MGLShapeSource initWithIdentifier:shape:options:]method or
MGLShapeSource.shapeproperty. Similarly, you can add
MGLPolygonFeatureobjects to the map as annotations using
-[MGLMapView addAnnotations:]and related methods.
In addition to adding data to the map, you can also extract data from the map:See more
-[MGLMapView visibleFeaturesAtPoint:]and related methods return feature objects that correspond to features in the source. This enables you to inspect the properties of features in vector tiles loaded by
MGLVectorSourceobjects. You also reuse these feature objects as overlay annotations.
@protocol MGLFeature <MGLAnnotation>
protocol MGLFeature : MGLAnnotation
MGLPolylineFeatureobject associates a polyline shape with an optional identifier and attributes.
A polyline feature is known as a LineString feature in GeoJSON.
MGLMultiPolylineFeatureobject associates a multipolyline shape with an optional identifier and attributes.
A multipolyline feature is known as a MultiLineString feature in GeoJSON.
MGLPointCollectionFeatureobject associates a point collection with an optional identifier and attributes.
A point collection feature is known as a MultiPoint feature in GeoJSON.
MGLShapeCollectionFeatureobject associates a shape collection with an optional identifier and attributes.
MGLShapeCollectionFeatureis most commonly used to add multiple shapes to a single
MGLShapeSource. Configure the appearance of an
MGLSource’s shape collection collectively using an
MGLSymbolStyleLayerobject, or use multiple instances of
MGLLineStyleLayerto configure the appearance of each kind of shape inside the collection.
A shape collection feature is known as a feature collection in GeoJSON.