MLNShapeSource class

MLNShapeSource is a map content source that supplies vector shapes to be shown on the map. The shapes may be instances of MLNShape or MLNShape, or they may be defined by local or external GeoJSON code. A shape source is added to an MLNStyle object along with an MLNStyle object. The vector style layer defines the appearance of any content supplied by the shape source. You can update a shape source by setting its shape or URL property.

MLNShapeSource is optimized for data sets that change dynamically and fit completely in memory. For large data sets that do not fit completely in memory, use the MLNComputedShapeSource or MLNComputedShapeSource class.

Each geojson source defined by the style JSON file is represented at runtime by an MLNShapeSource object that you can use to refine the map’s content and initialize new style layers. You can also add and remove sources dynamically using methods such as MLNStyle/addSource: and MLNStyle/sourceWithIdentifier:.

Any vector style layer initialized with a shape source should have a nil value in its sourceLayerIdentifier property.

Example

var coordinates: [CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 37.77, longitude: -122.42),
CLLocationCoordinate2D(latitude: 38.91, longitude: -77.04),
]
let polyline = MLNPolylineFeature(coordinates: &coordinates, count: UInt(coordinates.count))
let source = MLNShapeSource(identifier: "lines", features: [polyline], options: nil)
mapView.style?.addSource(source)

TODO: Cluster point data TODO: Use images to cluster point data TODO: Add live data Learn how to add data to your map using this MLNSource object.

Inheritance

Constructors

MLNShapeSource()
Returns a new instance of MLNShapeSource constructed with the default new method.
factory
MLNShapeSource.castFrom(ObjCObjectBase other)
Constructs a MLNShapeSource that points to the same underlying object as other.
MLNShapeSource.castFromPointer(Pointer<ObjCObject> other, {bool retain = false, bool release = false})
Constructs a MLNShapeSource that wraps the given raw object pointer.

Properties

debugDescription$1 → NSString
debugDescription
no setterinherited
description$1 → NSString
description
no setterinherited
hash$1 int
hash
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
identifier ↔ NSString
A string that uniquely identifies the source in the style to which it is added.
getter/setter pairinherited
isProxy bool
isProxy
no setterinherited
ref → ObjCObjectRef
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shape MLNShape?
The contents of the source. A shape can represent a GeoJSON geometry, a feature, or a collection of features.
getter/setter pair
superclass$1 → ObjCObjectBase
superclass
no setterinherited
URL ↔ NSURL?
The URL to the GeoJSON document that specifies the contents of the source.
getter/setter pair

Methods

autorelease() MLNShapeSource
autorelease
override
childrenOfCluster(MLNPointFeatureCluster cluster) → NSArray
Returns an array of map features that are the immediate children of the specified cluster on the next zoom level. The may include features that also conform to the MLNCluster protocol (currently only objects of type MLNCluster).
class$1() → ObjCObjectBase
class
inherited
conformsToProtocol$1(Protocol aProtocol) bool
conformsToProtocol:
inherited
copy() → ObjCObjectBase
copy
inherited
dealloc() → void
dealloc
inherited
doesNotRecognizeSelector(Pointer<ObjCSelector> aSelector) → void
doesNotRecognizeSelector:
inherited
featuresMatchingPredicate(NSPredicate? predicate) → NSArray
Returns an array of map features for this source, filtered by the given predicate.
forwardingTargetForSelector(Pointer<ObjCSelector> aSelector) → ObjCObjectBase
forwardingTargetForSelector:
inherited
forwardInvocation(NSInvocation anInvocation) → void
forwardInvocation:
inherited
init() MLNShapeSource
init
override
initWithIdentifier(NSString identifier, {required NSURL URL, NSDictionary? options}) MLNShapeSource
Returns a shape source with an identifier, URL, and dictionary of options for the source.
initWithIdentifier$1(NSString identifier, {MLNShape? shape, NSDictionary? options}) MLNShapeSource
Returns a shape source with an identifier, a shape, and dictionary of options for the source.
initWithIdentifier$2(NSString identifier, {required NSArray features, NSDictionary? options}) MLNShapeSource
Returns a shape source with an identifier, an array of features, and a dictionary of options for the source.
initWithIdentifier$3(NSString identifier, {required NSArray shapes, NSDictionary? options}) MLNShapeSource
Returns a shape source with an identifier, an array of shapes, and a dictionary of options for the source.
initWithIdentifier_(NSString identifier) MLNShapeSource
Returns a source initialized with an identifier.
override
isEqual(ObjCObjectBase object) bool
isEqual:
inherited
isKindOfClass(ObjCObjectBase aClass) bool
isKindOfClass:
inherited
isMemberOfClass(ObjCObjectBase aClass) bool
isMemberOfClass:
inherited
leavesOfCluster(MLNPointFeatureCluster cluster, {required int offset, required int limit}) → NSArray
Returns an array of map features that are the leaves of the specified cluster. ("Leaves" are the original points that belong to the cluster.)
methodForSelector(Pointer<ObjCSelector> aSelector) Pointer<NativeFunction<Void Function()>>
methodForSelector:
inherited
methodSignatureForSelector(Pointer<ObjCSelector> aSelector) → NSMethodSignature
methodSignatureForSelector:
inherited
mutableCopy() → ObjCObjectBase
mutableCopy
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performSelector(Pointer<ObjCSelector> aSelector) → ObjCObjectBase
performSelector:
inherited
performSelector$1(Pointer<ObjCSelector> aSelector, {required ObjCObjectBase withObject}) → ObjCObjectBase
performSelector:withObject:
inherited
performSelector$2(Pointer<ObjCSelector> aSelector, {required ObjCObjectBase withObject, required ObjCObjectBase withObject$1}) → ObjCObjectBase
performSelector:withObject:withObject:
inherited
release() → void
release
inherited
respondsToSelector(Pointer<ObjCSelector> aSelector) bool
respondsToSelector:
inherited
retain() MLNShapeSource
retain
override
retainCount() int
retainCount
inherited
self$1() MLNShapeSource
self
override
toString() String
A string representation of this object.
inherited
zone() Pointer<NSZone>
zone
inherited
zoomLevelForExpandingCluster(MLNPointFeatureCluster cluster) double
Returns the zoom level at which the given cluster expands.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

alloc() MLNShapeSource
alloc
override
allocWithZone(Pointer<NSZone> zone) MLNShapeSource
allocWithZone:
override
isInstance(ObjCObjectBase obj) bool
Returns whether obj is an instance of MLNShapeSource.
override
new$() MLNShapeSource
new
override