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<NSString *, id> *)options;

    Swift

    init(identifier: String, geoJSONData data: NSData, options: [String : AnyObject]?)

    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<NSString *, id> *)options;

    Swift

    init(identifier: String, URL url: NSURL, options: [String : AnyObject]?)

    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<NSString *, id> *)options;

    Swift

    init(identifier: String, features: [AnyObject], options: [String : AnyObject]?)

    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 to nil. This property is unavailable until the receiver is passed into -[MGLStyle addSource].

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable)
        NSArray<id<MGLFeature>> *features;

    Swift

    var features: [AnyObject]? { get set }
  • 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 -initWithIdentifier:URL:options or -initWithIdentifier:features:options, this property is set to nil. This property is unavailable until the receiver is passed into -[MGLStyle addSource].

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSData *geoJSONData;

    Swift

    @NSCopying var geoJSONData: NSData? { get set }
  • URL

    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 to nil.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) NSURL *URL;

    Swift

    var URL: NSURL? { get set }