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

Dynamic Layer Ordering

Dynamic Layer Ordering

You can change the z-order of the layers dynamically 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 how the route looks like in details.



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];
}

 

You are here