TGMapData


@interface TGMapData : NSObject

A TGMapData is a convenience class to display point, polygons or polylines from a dynamic data layer. The data layer will be styled according to the scene file using the provided data layer name.

In your stylesheet, add a layer with the name of the data layer you want to add in your client application:

layers:
    mz_route_line_transit:
       data: { source: mz_route_line_transit }
    draw:
       polylines:
           color: function() { return feature.color || '#06a6d4'; }
           order: 500
           width: 10px

In your implementation, to add a polyline fitting under the mz_route_line_transit layer:

// Create a data layer in the TGMapView mapView
var dataLayer = mapView.addDataLayer(name: "mz_Route_line_transit");

var line = TGGeoPolyline()

// Add some coordinates to the polyline
line.addPoint(point: CLLocationCoordinate2DMake(longitude0, latitude0))
line.addPoint(point: CLLocationCoordinate2DMake(longitude1, latitude1))

// Set the data properties
var properties = ["type": "line", "color": "#D2655F"]

// Add the line to the data layer
dataLayer.add(polyline: line, properties: properties);
  • Adds a point coordinate to the data source.

    Declaration

    Objective-C

    - (void)addPoint:(CLLocationCoordinate2D)point
        withProperties:(nonnull TGFeatureProperties *)properties;

    Swift

    func addPoint(_ point: CLLocationCoordinate2D, withProperties properties: [String : String])

    Parameters

    point

    the geographic coordinates of the point to add to the data source

    properties

    the feature properties

  • Adds a polygon geometry to the data source.

    Declaration

    Objective-C

    - (void)addPolygon:(nonnull TGGeoPolygon *)polygon
        withProperties:(nonnull TGFeatureProperties *)properties;

    Swift

    func add(_ polygon: TGGeoPolygon, withProperties properties: [String : String])

    Parameters

    polygon

    the polygon geometry to add to the data source

    properties

    the feature properties

  • Adds a polyline to the data source.

    Declaration

    Objective-C

    - (void)addPolyline:(nonnull TGGeoPolyline *)polyline
         withProperties:(nonnull TGFeatureProperties *)properties;

    Swift

    func add(_ polyline: TGGeoPolyline, withProperties properties: [String : String])

    Parameters

    polyline

    the polyline geometry to add to the data source

    properties

    the feature properties

  • Adds features described in a GeoJSON string to the data source. The string must be formatted according to the GeoJSON specifications.

    Declaration

    Objective-C

    - (void)addGeoJson:(nonnull NSString *)data;

    Swift

    func addGeoJson(_ data: String)

    Parameters

    data

    the GeoJSON formatted string to add to the data source

  • Clears the data source from all the added features.

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()
  • Definitely removes the data source from the map view. Any future usage of this MapData object will be a no-op.

    Declaration

    Objective-C

    - (BOOL)remove;

    Swift

    func remove() -> Bool

    Return Value

    YES if removal was successful

  • The name of the data source

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSString *_Nonnull name;

    Swift

    var name: String { get }
  • The map view this data source is on

    Declaration

    Objective-C

    @property (readonly, nonatomic) TGMapView *_Nullable mapView;

    Swift

    weak var mapView: TGMapView? { get }