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 point, coordinates or bounding box 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:

_

Layer layer = LayerFactory.createLayer(layerJson);
tomtomMap.getStyleSettings().addLayer(layer);
val layer = LayerFactory.createLayer(layerJson)
tomtomMap.styleSettings.addLayer(layer)

 

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

_

List<String> layerIds = ImmutableList.of(GEOJSON_LAYER_ID);
FeatureCollection featureCollection = tomtomMap.getDisplaySettings().featuresAtPoint(point, layerIds);
val layerIds = listOf(GEOJSON_LAYER_ID)
val featureCollection = tomtomMap.displaySettings.featuresAtPoint(point, layerIds)

 

To query the style for specific layer features in a given screen box call:

_

FeatureCollection featureCollection = tomtomMap.getDisplaySettings().featuresInScreenRect(mapViewPort, layerIds);
val featureCollection = tomtomMap.displaySettings.featuresInScreenRect(mapViewPort, LAYER_LIST)

 

To obtain and process features:

_

List<Feature> featureList = featureCollection.getFeatures();
FuncUtils.forEach(featureList, feature -> FuncUtils.apply(feature.getId(), this::displayToast));
val featureList = featureCollection.features
FuncUtils.forEach(featureList) { feature -> FuncUtils.apply(feature.id) { id -> displayToast(id) } }


image

GeoJSON polygon clicked

image

Features in viewport

You are here