Sorry, you need to enable JavaScript to visit this website.

Interactive map layers

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 screen rect within a specified layer in the style.

Sample use case 1: You want to display an information if user click on 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

You are here