THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Interactive map layers

Retrieve data of a feature (e.g., ID, geometry) from layers in the style by querying for rendered features at a screen point, coordinates, or the screen rect within a specified layer in the style.

Sample use case 1: You want to display information if the user clicks on a layer that you added.

Sample use case 2: You want to return all visible features in a viewport.

To create a layer and dynamically add it to the style:

let layerMap = TTMapLayer.create(withStyleJSON: layerJSON, withMap: mapView)
currentStyle.add(layerMap!)
TTMapLayer *layerMap = [TTMapLayer createWithStyleJSON:layerJSON withMap:self.mapView]
[self.currentStyle addLayer:layerMap];

To query the style for specific layer features at a given coordinates call:

let geoJSONFeatures = mapView.features(atCoordinates: coordinate, inStyleLayerIdentifiers: ["IL-test-layer-outline"])
TTGeoJSONFeatureCollection *geoJSONFeatures = [self.mapView featuresAtCoordinates:coordinate inStyleLayerIdentifiers:[NSSet setWithObject:@"IL-test-layer-outline"]];

To query the style for specific layer features in a given screen rect e.g., viewport:

let geoJSONFeatures = mapView.features(atScreenRect: mapView.bounds, inStyleLayerIdentifiers: ["IL-test-layer-outline"])
TTGeoJSONFeatureCollection *geoJSONFeatures = [self.mapView featuresAtScreenRect:self.mapView.bounds inStyleLayerIdentifiers:[NSSet setWithObject:@"IL-test-layer-outline"]];

image

GeoJSON polygon clicked

image

Features in viewport