MGLGeoJSONSource
@interface MGLGeoJSONSource : MGLSource
A GeoJSON source.
-
The contents of the source.
If the receiver was initialized using
-initWithSourceIdentifier:URL:
, this property is set tonil
. This property is unavailable until the receiver is passed into-[MGLStyle addSource]
.Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSArray<id<MGLFeature>> *features;
Swift
var features: [AnyObject]? { get }
-
A GeoJSON representation of the contents of the source.
Use the
features
property instead to get an object representation of the contents. Alternatively, use NSJSONSerialization with the value of this property to transform it into Foundation types.If the receiver was initialized using
-initWithSourceIdentifier:URL:
, this property is set tonil
. This property is unavailable until the receiver is passed into-[MGLStyle addSource]
.Declaration
Objective-C
@property (readonly, copy, nonatomic, nullable) NSData *geoJSONData;
Swift
@NSCopying var geoJSONData: NSData? { get }
-
The URL to the GeoJSON document that specifies the contents of the source.
If the receiver was initialized using
-initWithSourceIdentifier:geoJSONData:
, this property is set tonil
.Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSURL *URL;
Swift
var URL: NSURL? { get }
-
Initializes a source with the given identifier and GeoJSON data.
Declaration
Objective-C
- (nonnull instancetype)initWithSourceIdentifier: (nonnull NSString *)sourceIdentifier geoJSONData:(nonnull NSData *)data;
Swift
init(sourceIdentifier: String, geoJSONData data: NSData)
Parameters
sourceIdentifier
A string that uniquely identifies the source.
geoJSONData
An NSData object representing GeoJSON source code.
-
Initializes a source with the given identifier, GeoJSON data, and a dictionary of options for the source as specified by the the style specification.
Declaration
Objective-C
- (nonnull instancetype) initWithSourceIdentifier:(nonnull NSString *)sourceIdentifier geoJSONData:(nonnull NSData *)data options:(nonnull NSDictionary<NSString *, id> *)options;
Swift
init(sourceIdentifier: String, geoJSONData data: NSData, options: [String : AnyObject])
Parameters
sourceIdentifier
A string that uniquely identifies the source.
geoJSONData
An NSData object representing GeoJSON source code.
options
An NSDictionary of attributes for this source.
-
Initializes a source with the given identifier and URL.
Declaration
Objective-C
- (nonnull instancetype)initWithSourceIdentifier: (nonnull NSString *)sourceIdentifier URL:(nonnull NSURL *)url;
Swift
init(sourceIdentifier: String, URL url: NSURL)
Parameters
sourceIdentifier
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.
-
Initializes a source with the given identifier, a URL, and a dictionary of options for the source as specified by the the style specification.
Declaration
Objective-C
- (nonnull instancetype) initWithSourceIdentifier:(nonnull NSString *)sourceIdentifier URL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *, id> *)options;
Swift
init(sourceIdentifier: String, URL url: NSURL, options: [String : AnyObject])
Parameters
sourceIdentifier
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 attributes for this source.