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 point, coordinates, or a bounding box within a specified layer in the style.

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