MGLGeoJSONSource
@interface MGLGeoJSONSource : MGLSource
A GeoJSON source.
-
Returns a GeoJSON source initialized with an identifier, GeoJSON data, and a dictionary of options for the source according to the style specification.
Declaration
Objective-C
- (nonnull instancetype) initWithIdentifier:(nonnull NSString *)identifier geoJSONData:(nonnull NSData *)data options:(nullable NSDictionary<MGLGeoJSONSourceOption, id> *)options;
Swift
init(identifier: String, geoJSONData data: Data, options: [MGLGeoJSONSourceOption : Any]? = nil)
Parameters
identifier
A string that uniquely identifies the source.
geoJSONData
An
NSData
object representing GeoJSON source code.options
An
NSDictionary
of options for this source.Return Value
An initialized GeoJSON source.
-
Returns a GeoJSON source with an identifier, URL, and dictionary of options for the source according to the style specification.
Declaration
Objective-C
- (nonnull instancetype) initWithIdentifier:(nonnull NSString *)identifier URL:(nonnull NSURL *)url options:(nullable NSDictionary<MGLGeoJSONSourceOption, id> *)options;
Swift
init(identifier: String, url: URL, options: [MGLGeoJSONSourceOption : Any]? = nil)
Parameters
identifier
A string that uniquely identifies the source.
URL
An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle.
options
An
NSDictionary
of options for this source.Return Value
An initialized GeoJSON source.
-
Returns a GeoJSON source with an identifier, features dictionary, and dictionary of options for the source according to the style specification.
Declaration
Objective-C
- (nonnull instancetype) initWithIdentifier:(nonnull NSString *)identifier features:(nonnull NSArray<id<MGLFeature>> *)features options:(nullable NSDictionary<MGLGeoJSONSourceOption, id> *)options;
Parameters
identifier
A string that uniquely identifies the source.
features
An array of features that conform to the
MGLFeature
protocol.options
An
NSDictionary
of options for this source.Return Value
An initialized GeoJSON source.
-
The contents of the source.
If the receiver was initialized using
-initWithIdentifier:URL:options:
, this property is set tonil
. This property is unavailable until the receiver is passed into-[MGLStyle addSource]
.Declaration
Objective-C
@property (assign, readwrite, nonatomic, nullable) NSArray<id<MGLFeature>> *features;
-
A GeoJSON representation of the contents of the source.
Use the
features
property instead to get an object representation of the contents. Alternatively, useNSJSONSerialization
with the value of this property to transform it into Foundation types.If the receiver was initialized using
-initWithIdentifier:URL:options
or-initWithIdentifier:features:options
, this property is set tonil
. This property is unavailable until the receiver is passed into-[MGLStyle addSource]
.Declaration
Objective-C
@property (readwrite, copy, nonatomic, nullable) NSData *geoJSONData;
Swift
var geoJSONData: Data? { get set }
-
The URL to the GeoJSON document that specifies the contents of the source.
If the receiver was initialized using
-initWithIdentifier:geoJSONData:options
, this property is set tonil
.Declaration
Objective-C
@property (assign, readwrite, nonatomic, nullable) NSURL *URL;
Swift
var url: URL? { get set }