MGLComputedShapeSource
@interface MGLComputedShapeSource : MGLSource
MGLComputedShapeSource
is a map content source that supplies vector shapes,
one tile at a time, to be shown on the map on demand. You implement a class
conforming to the MGLComputedShapeSourceDataSource
protocol that returns
instances of MGLShape
or MGLFeature
, then add a computed shape source to an
MGLStyle
object along with an MGLVectorStyleLayer
object. The vector style
layer defines the appearance of any content supplied by the computed shape
source.
MGLComputedShapeSource
is similar to MGLShapeSource
but is optimized for
data sets that change dynamically or are too large to fit completely in memory.
It is also useful for data that is divided into tiles in a format other than
Mapbox Vector Tiles. For
GeoJSON data, use the MGLShapeSource
class.
For static tiles or Mapbox Vector Tiles, use the MGLVectorTileSource
class.
You can add and remove sources dynamically using methods such as
-[MGLStyle addSource:]
and -[MGLStyle sourceWithIdentifier:]
. This class
cannot be represented in a style JSON file; you must add it ot the style at
runtime.
-
Returns a custom shape data source initialized with an identifier, and a dictionary of options for the source according to the style specification.
This class supports the following options:
MGLShapeSourceOptionMinimumZoomLevel
,MGLShapeSourceOptionMaximumZoomLevel
,MGLShapeSourceOptionBuffer
,MGLShapeSourceOptionSimplificationTolerance
,MGLShapeSourceOptionWrapsCoordinates
, andMGLShapeSourceOptionClipsCoordinates
. Shapes provided by a computed shape source cannot be clustered.Declaration
Objective-C
- (nonnull instancetype) initWithIdentifier:(nonnull NSString *)identifier options: (nullable NSDictionary<MGLShapeSourceOption, id> *)options;
Swift
init(identifier: String, options: [MGLShapeSourceOption : Any]? = nil)
Parameters
identifier
A string that uniquely identifies the source.
options
An
NSDictionary
of options for this source. -
Returns a custom shape data source initialized with an identifier, data source, and a dictionary of options for the source according to the style specification.
This class supports the following options:
MGLShapeSourceOptionMinimumZoomLevel
,MGLShapeSourceOptionMaximumZoomLevel
,MGLShapeSourceOptionBuffer
,MGLShapeSourceOptionSimplificationTolerance
,MGLShapeSourceOptionWrapsCoordinates
, andMGLShapeSourceOptionClipsCoordinates
. Shapes provided by a computed shape source cannot be clustered.Declaration
Objective-C
- (nonnull instancetype) initWithIdentifier:(nonnull NSString *)identifier dataSource:(nonnull id<MGLComputedShapeSourceDataSource>)dataSource options: (nullable NSDictionary<MGLShapeSourceOption, id> *)options;
Swift
convenience init(identifier: String, dataSource: MGLComputedShapeSourceDataSource, options: [MGLShapeSourceOption : Any]? = nil)
Parameters
identifier
A string that uniquely identifies the source.
options
An
NSDictionary
of options for this source. -
Invalidates all the features and properties intersecting with or contained in the specified bounds. New fetch requests will immediately be invoked on the
MGLComputedShapeSourceDataSource
.Declaration
Objective-C
- (void)invalidateBounds:(MGLCoordinateBounds)bounds;
Swift
func invalidateBounds(_ bounds: MGLCoordinateBounds)
Parameters
bounds
Coordinate bounds to invalidate.
-
Invalidates all the feautres and properties of a given tile. A new fetch request will immediately be invoked on the
MGLComputedShapeSourceDataSource
.Declaration
Objective-C
- (void)invalidateTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel;
Swift
func invalidateTileAt(x: UInt, y: UInt, zoomLevel: UInt)
Parameters
x
Tile X coordinate.
y
Tile Y coordinate.
zoomLevel
Tile zoom level.
-
Set a new set of features for a tile. This method can be invkoed from background threads. For best performance, use this method only to update tiles that have already been requested through
MGLComputedShapeSourceDataSource.
Declaration
Objective-C
- (void)setFeatures:(nonnull NSArray<MGLShape<MGLFeature> *> *)features inTileAtX:(NSUInteger)x y:(NSUInteger)y zoomLevel:(NSUInteger)zoomLevel;
Parameters
features
Features for the tile.
x
Tile X coordinate.
y
Tile Y coordinate.
zoomLevel
Tile zoom level.
-
An object that implements the
MGLComputedShapeSourceDataSource
protocol that will be queried for tile data.Declaration
Objective-C
@property (nonatomic, weak, readwrite, nullable) id<MGLComputedShapeSourceDataSource> dataSource;
Swift
weak var dataSource: MGLComputedShapeSourceDataSource? { get set }
-
A queue that calls to the data source will be made on.
Declaration
Objective-C
@property (nonatomic, readonly) NSOperationQueue *_Nonnull requestQueue;
Swift
var requestQueue: OperationQueue { get }