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

Dynamic Layer Ordering

Dynamic Layer Ordering

You can dynamically change the z-order of the layers on the map to make the layers important to your use case visible on top of other layers.

Sample use case : You placed images on the map in your app but your users can bring the route and the road network on top of the images to see what the route looks like in detail.

image

Images

_

let layersImages = currentStyle.getLayersByRegex("img-id.*")
layersImages.forEach { currentStyle.moveLayer(toFront: $0) }
NSArray<TTMapLayer *> *layersImages = [self.currentStyle getLayersByRegex:@"img-id.*"];
for (TTMapLayer *layer in layersImages) {
    [self.currentStyle moveLayerToFront:layer];
}

 

image

GeoJSON

_

let layerRoute = currentStyle.getLayerByID("layer-line-id")
currentStyle.moveLayer(toFront: layerRoute!)
TTMapLayer *layerRoute = [self.currentStyle getLayerByID:@"layer-line-id"];
[self.currentStyle moveLayerToFront:layerRoute];
break;

 

image

Roads

_

let layersRoads = currentStyle.getLayersBySourceLayerRegexs([".*[rR]oad.*", ".*[mM]otorway.*"])
layersRoads.forEach { currentStyle.moveLayer(toFront: $0) }
NSArray<TTMapLayer *> *layersRoads = [self.currentStyle getLayersBySourceLayerRegexs:[NSArray arrayWithObjects:@".*[rR]oad.*", @".*[mM]otorway.*", nil]];
for (TTMapLayer *layer in layersRoads) {
    [self.currentStyle moveLayerToFront:layer];
}