Style Primitives
MGLFeature
The MGLFeature
protocol is used to provide details about geographic features contained in an MGLShapeSource
or MGLVectorTileSource
object. Each concrete subclass of MGLShape
in 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
using the -[MGLShapeSource initWithIdentifier:shape:options:]
method or MGLShapeSource.shape
property.
In addition to adding data to the map, you can also extract data from the map: -[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 MGLVectorTileSource
objects. You also reuse these feature objects as overlay annotations.
While it is possible to add MGLFeature
-conforming objects to the map as annotations using -[MGLMapView addAnnotations:]
and related methods, doing so has trade-offs:
-
Features added as annotations will not have
identifier
orattributes
properties when used with feature querying. -
Features added as annotations become interactive. Taps and selection can be handled in
-[MGLMapViewDelegate mapView:didSelectAnnotation:]
.
Declaration
Objective-C
@protocol MGLFeature <MGLAnnotation>
Swift
protocol MGLFeature : MGLAnnotation
MGLPointFeature
An MGLPointFeature
object associates a point shape with an optional identifier and attributes.
Declaration
Objective-C
@interface MGLPointFeature : MGLPointAnnotation <MGLFeature>
Swift
class MGLPointFeature : MGLPointAnnotation, MGLFeature
MGLPointFeatureCluster
An MGLPointFeatureCluster
object associates a point shape (with an optional identifier and attributes) and represents a point cluster.
See
Declaration
Objective-C
@interface MGLPointFeatureCluster : MGLPointFeature <MGLCluster>
Swift
class MGLPointFeatureCluster : MGLPointFeature, MGLCluster
MGLPolygonFeature
An MGLPolygonFeature
object associates a polygon shape with an optional identifier and attributes.
Declaration
Objective-C
@interface MGLPolygonFeature : MGLPolygon <MGLFeature>
Swift
class MGLPolygonFeature : MGLPolygon, MGLFeature
MGLPolylineFeature
An MGLPolylineFeature
object associates a polyline shape with an optional identifier and attributes.
A polyline feature is known as a LineString feature in GeoJSON.
Declaration
Objective-C
@interface MGLPolylineFeature : MGLPolyline <MGLFeature>
Swift
class MGLPolylineFeature : MGLPolyline, MGLFeature
MGLMultiPolygonFeature
An MGLMultiPolygonFeature
object associates a multipolygon shape with an optional identifier and attributes.
Declaration
Objective-C
@interface MGLMultiPolygonFeature : MGLMultiPolygon <MGLFeature>
Swift
class MGLMultiPolygonFeature : MGLMultiPolygon, MGLFeature
MGLMultiPolylineFeature
An MGLMultiPolylineFeature
object associates a multipolyline shape with an optional identifier and attributes.
A multipolyline feature is known as a MultiLineString feature in GeoJSON.
Declaration
Objective-C
@interface MGLMultiPolylineFeature : MGLMultiPolyline <MGLFeature>
Swift
class MGLMultiPolylineFeature : MGLMultiPolyline, MGLFeature
MGLPointCollectionFeature
An MGLPointCollectionFeature
object associates a point collection with an optional identifier and attributes.
A point collection feature is known as a MultiPoint feature in GeoJSON.
Declaration
Objective-C
@interface MGLPointCollectionFeature : MGLPointCollection <MGLFeature>
Swift
class MGLPointCollectionFeature : MGLPointCollection, MGLFeature
MGLShapeCollectionFeature
An MGLShapeCollectionFeature
object associates a shape collection with an optional identifier and attributes.
MGLShapeCollectionFeature
is most commonly used to add multiple shapes to a single MGLShapeSource
. Configure the appearance of an MGLSource
’s shape collection collectively using an MGLSymbolStyleLayer
object, or use multiple instances of MGLCircleStyleLayer
, MGLFillStyleLayer
, and MGLLineStyleLayer
to configure the appearance of each kind of shape inside the collection.
A shape collection feature is known as a feature collection in GeoJSON.
Declaration
Objective-C
@interface MGLShapeCollectionFeature : MGLShapeCollection <MGLFeature>
Swift
class MGLShapeCollectionFeature : MGLShapeCollection, MGLFeature
MGLEmptyFeature
An MGLEmptyFeature
object associates an empty shape with an optional identifier and attributes.
Declaration
Objective-C
@interface MGLEmptyFeature : MGLShape <MGLFeature>
Swift
class MGLEmptyFeature : MGLShape, MGLFeature
iOS SDK
Examples
SDK JS Reference
- Annotations
- Appendices
- NSExpression(MGLAdditions)
- NSValue(MGLAdditions)
- NSValue(MGLCircleStyleLayerAdditions)
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- NSValue(MGLLineStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLAccountManager
- MGLAnnotationImage
- MGLAnnotationView
- MGLAttributedExpression
- MGLAttributionInfo
- MGLBackgroundStyleLayer
- MGLCircleStyleLayer
- MGLClockDirectionFormatter
- MGLCompassButton
- MGLCompassDirectionFormatter
- MGLComputedShapeSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLFillExtrusionStyleLayer
- MGLFillStyleLayer
- MGLForegroundStyleLayer
- MGLHeatmapStyleLayer
- MGLHillshadeStyleLayer
- MGLImageSource
- MGLLight
- MGLLineStyleLayer
- MGLLoggingConfiguration
- MGLMapCamera
- MGLMapSnapshot
- MGLMapSnapshotOptions
- MGLMapSnapshotOverlay
- MGLMapSnapshotter
- MGLMapView
- MGLMultiPoint
- MGLMultiPolygon
- MGLMultiPolyline
- MGLNetworkConfiguration
- MGLOfflinePack
- MGLOfflineStorage
- MGLPointAnnotation
- MGLPointCollection
- MGLPolygon
- MGLPolyline
- MGLRasterStyleLayer
- MGLRasterTileSource
- MGLShape
- MGLShapeCollection
- MGLShapeOfflineRegion
- MGLShapeSource
- MGLSource
- MGLStyle
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLTilePyramidOfflineRegion
- MGLTileSource
- MGLUserLocation
- MGLUserLocationAnnotationView
- MGLUserLocationAnnotationViewStyle
- MGLVectorStyleLayer
- MGLVectorTileSource
- MGLAnnotationVerticalAlignment
- MGLAnnotationViewDragState
- MGLAttributionInfoStyle
- MGLCirclePitchAlignment
- MGLCircleScaleAlignment
- MGLCircleTranslationAnchor
- MGLDEMEncoding
- MGLErrorCode
- MGLFillExtrusionTranslationAnchor
- MGLFillTranslationAnchor
- MGLHillshadeIlluminationAnchor
- MGLIconAnchor
- MGLIconPitchAlignment
- MGLIconRotationAlignment
- MGLIconTextFit
- MGLIconTranslationAnchor
- MGLLightAnchor
- MGLLineCap
- MGLLineJoin
- MGLLineTranslationAnchor
- MGLLoggingLevel
- MGLMapDebugMaskOptions
- MGLOfflinePackState
- MGLOrnamentPosition
- MGLOrnamentVisibility
- MGLRasterResamplingMode
- MGLResourceKind
- MGLSymbolPlacement
- MGLSymbolZOrder
- MGLTextAnchor
- MGLTextJustification
- MGLTextPitchAlignment
- MGLTextRotationAlignment
- MGLTextTransform
- MGLTextTranslationAnchor
- MGLTextWritingMode
- MGLTileCoordinateSystem
- MGLUserTrackingMode
- Formatters
- Geometry
- Location Updates
- Maps
- Offline Maps
- Other Categories
- Other Classes
- Other Constants
- Other Enumerations
- Other Functions
- Other Protocols
- Other Structures
- Other Type Definitions
- Primitive Shapes
- MGLAnnotation
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCluster
- MGLComputedShapeSourceDataSource
- MGLFeature
- MGLLocationManager
- MGLLocationManagerDelegate
- MGLMapSnapshotterDelegate
- MGLMapViewDelegate
- MGLOfflineRegion
- MGLOfflineStorageDelegate
- MGLOverlay
- MGLStylable
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- Style Content
- Style Layers
- Style Primitives
- Styling the Map
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- User Interaction
- Customizing Fonts
- Information for Style Authors
- Gesture Recognizers
- Info.plist Keys
- Migrating to Expressions
- Predicates and expressions
- Tile URL Templates
- Working with GeoJSON Data