Classes

The following classes are available globally.

  • A camera position defining a viewpoint for a map.

    See more

    Declaration

    Objective-C

    
    @interface TGCameraPosition : NSObject <NSCopying>

    Swift

    class TGCameraPosition : NSObject, NSCopying
  • Helper class to contain a polygon geometry for use in -[TGMarker polygon].

    The polygon winding order and internal polygons must be set according to the GeoJSON specification.

    See more

    Declaration

    Objective-C

    
    @interface TGGeoPolygon : NSObject

    Swift

    class TGGeoPolygon : NSObject
  • Helper class to contain a polyline geometry for use in -[TGMarker polyline].

    Set the geometry of a marker to a polyline along the given coordinates; _coordinates is a pointer to a sequence of _count LngLats; markers can have their geometry set multiple times with possibly different geometry types; returns true if the marker ID was found and successfully updated, otherwise returns false.

    See more

    Declaration

    Objective-C

    
    @interface TGGeoPolyline : NSObject

    Swift

    class TGGeoPolyline : NSObject
  • Data structure holding the result of a label selection that occured on the map view.

    See -[TGMapView pickLabelAt:] and [TGMapViewDelegate mapView:didSelectLabel:atScreenPosition:].

    See more

    Declaration

    Objective-C

    
    @interface TGLabelPickResult : NSObject

    Swift

    class TGLabelPickResult : 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);
    
    See more

    Declaration

    Objective-C

    
    @interface TGMapData : NSObject

    Swift

    class TGMapData : NSObject
  • TGMapView is a flexible and customizable map view managing the lifecycle of an OpenGL ES map. This view provides gesture handlers for tap, double-tap, long press, pan, pinch, rotate, and shove gestures.

    The public interface provides dynamic map marker placement, change of camera view settings, and map description changes through scene updates.

    This view uses scene files described by the Tangram scene format allowing you to fully customize your map using your own data. Some pre-made basemap styles can be found here using Nextzen data sources.

    To use basemap styles you can sign up for an API key and load it through your application:

    let sceneURL = URL("https://www.nextzen.org/carto/bubble-wrap-style/9/bubble-wrap-style.zip");
    let sceneUpdates = [ TGSceneUpdate(path: "global.sdk_api_key", value: "YOUR_API_KEY") ];
    view.loadScene(from: sceneURL, with: sceneUpdates);
    

    Note

    All the screen positions used in this inteface are in logical pixel or drawing coordinate system (based on a UIKit coordinate system), which is independent of the phone pixel density. Refer to the Apple documentation regarding Coordinate Systems and Drawing in iOS for more information.
    See more

    Declaration

    Objective-C

    
    @interface TGMapView : UIView <UIGestureRecognizerDelegate>

    Swift

    class TGMapView : UIView, UIGestureRecognizerDelegate
  • Marker interface that makes you able to add icons, polylines and polygons to the map view.

    The marker style should defined using the Tangram YAML syntax.

    See more

    Declaration

    Objective-C

    
    @interface TGMarker : NSObject

    Swift

    class TGMarker : NSObject
  • Data structure holding the result of a marker selection that occured on the map view.

    See -[TGMapView pickMarkerAt:] and [TGMapViewDelegate mapView:didSelectMarker:atScreenPosition:].

    See more

    Declaration

    Objective-C

    
    @interface TGMarkerPickResult : NSObject

    Swift

    class TGMarkerPickResult : NSObject
  • Represents a data structure to specify a YAML path and the corresponding value for a Tangram scene update.

    Example to update an API key for a source defined like this in your stylesheet:

    sources:
        osm:
            type: MVT
            url:  https://tile.mapzen.com/mapzen/vector/v1/all/{z}/{x}/{y}.mvt
            max_zoom: 16
            url_params:
                api_key: vector-tiles-tyHL4AY
    
    view.queueSceneUpdates(sceneUpdates: [ TGSceneUpdate(path: "sources.osm.url_params", value: "{ api_key: \(YOUR_API_KEY) }") ])
    view.applySceneUpdates()
    
    See more

    Declaration

    Objective-C

    
    @interface TGSceneUpdate : NSObject

    Swift

    class TGSceneUpdate : NSObject