MGLPointCollection
@interface MGLPointCollection : MGLShape <MGLOverlay>
An MGLPointCollection
object represents a shape consisting of one or more disconnected vertices, specified as CLLocationCoordinate2D
instances. The points in the collection may be related but are not connected spatially. For example, you could use a point collection to represent all the trees in an orchard.
You can add point collections to the map by adding them to an MGLShapeSource
object. Configure the appearance of an MGLShapeSource
’s or MGLVectorTileSource
’s point collections collectively using an MGLCircleStyleLayer
or MGLSymbolStyleLayer
object. To access a point collection’s attributes, use an MGLPointCollectionFeature
object.
You cannot add an MGLPointCollection
object directly to a map view as an annotation. However, you can create individual MGLPointAnnotation
objects from the coordinates
array and add those annotation objects to the map view using the -[MGLMapView addAnnotations:]
method.
A point collection is known as a MultiPoint geometry in GeoJSON. Do not confuse MGLPointCollection
with MGLMultiPoint
, the abstract superclass of MGLPolyline
and MGLPolygon
.
+pointCollectionWithCoordinates:count:
Creates and returns a MGLPointCollection
object from the specified set of coordinates.
Declaration
Objective-C
+ (instancetype)pointCollectionWithCoordinates:
(const CLLocationCoordinate2D *)coords
count:(NSUInteger)count;
Swift
convenience init!(coordinates coords: UnsafePointer<CLLocationCoordinate2D>!, count: UInt)
Parameters
coords
The array of coordinates defining the shape. The data in this array is copied to the new object.
count
The number of items in the coords
array.
Return Value
A new point collection object.
coordinates
The array of coordinates associated with the shape.
Declaration
Objective-C
@property (nonatomic, readonly) CLLocationCoordinate2D *coordinates;
Swift
var coordinates: UnsafeMutablePointer<CLLocationCoordinate2D>! { get }
pointCount
The number of coordinates associated with the shape.
Declaration
Objective-C
@property (nonatomic, readonly) NSUInteger pointCount;
Swift
var pointCount: UInt { get }
-getCoordinates:range:
Retrieves one or more coordinates associated with the shape.
Declaration
Objective-C
- (void)getCoordinates:(CLLocationCoordinate2D *)coords range:(NSRange)range;
Swift
func getCoordinates(_ coords: UnsafeMutablePointer<CLLocationCoordinate2D>!, range: NSRange)
Parameters
coords
On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data.
range
The range of points you want. The location
field indicates the first point you are requesting, with 0
being the first point, 1
being the second point, and so on. The length
field indicates the number of points you want. The array in coords
must be large enough to accommodate the number of requested coordinates.
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