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
  • A closed polygon with optional holes.

    The polygon is defined by a list of rings. Each ring is represented with a TGGeoPolyline. The first and last points in each ring are joined to form a closed shape. The first ring represents the exterior of the polygon and any subsequent rings become holes that are cut out of the polygon.

    See more

    Declaration

    Objective-C

    
    @interface TGGeoPolygon : NSObject

    Swift

    class TGGeoPolygon : NSObject
  • A shape made of connected line segments.

    The shape is defined by an ordered list of geographic coordinates.

    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 enables you to dynamically create map features to be rendered in the current map scene.

    To render features from a TGMapData in your map scene, add a layer in your scene file with a data source set to a new source name. This source name will correspond to the name of your TGMapData instance.

    Example:

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

    In your application, create a TGMapData instance with the same name using -[TGMapView addDataLayer:generateCentroid:] and assign map features to it.

    Example (Objective-C):

    CLLocationCoordinate2D polylinePoints[] = { ... };
    TGGeoPolyline *polyline = [[TGGeoPolyline alloc] initWithCoordinates:polylinePoints count:polylinePointCount];
    TGFeatureProperties *properties = @{ @"type" : @"line", @"color" : @"#D2655F" };
    TGMapFeature *feature = [TGMapFeature mapFeatureWithPolyline:polyline properties:properties];
    TGMapData *mapData = [mapView addDataLayer:@"route_line_transit_data", generateCentroid:NO];
    [mapData setFeatures:@[feature]];
    

    Example (Swift):

    var polyline = TGGeoPolyline(coordinates: polylinePoints, count: polylinePointCount);
    var properties = ["type": "line", "color": "#D2655F"];
    var feature = TGMapFeature(polyline: polyline, properties: properties);
    var mapData = mapView.addDataLayer(name: "mz_route_line_transit_data");
    mapData.setFeatures([feature]);
    
    See more

    Declaration

    Objective-C

    
    @interface TGMapData : NSObject

    Swift

    class TGMapData : NSObject
  • A map object defined by a geometry and a set of properties.

    Map features can be assigned to a TGMapData to be rendered in the current scene.

    Create a map feature with either a point, polyline, or polygon geometry using the factory methods. Access the geometry using the method for that geometry type - the other methods will return nil.

    See more

    Declaration

    Objective-C

    
    @interface TGMapFeature : NSObject

    Swift

    class TGMapFeature : 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