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

Switching Map Layers

Switching Map Layers

Allow your users to dynamically toggle the visibility of map entities. You can hide map layers to get
the level of detail you need and highlight the layers that are important for your use case.

Sample use case: You want to provide a clear map view for driving that focuses on the road network
in your app. You can achieve that by switching off some map layers e.g. woodland, build-up areas, etc.
You can turn these layers back on at run time to bring back the details for a better map viewing experience.

The following articles provide more information on map layer visibility and map layers available in
the default style: Map layers, Default style.

You can retrieve all layers available in the style or only those that match provided regex.
To filter, you can use layer ID or source layer ID properties, as shown below:



image

Map Road network layers

_

layers = currentStyle.getLayersBySourceLayerRegexs([".*[rR]oad.*", ".*[mM]otorway.*"])
layers = [self.currentStyle getLayersBySourceLayerRegexs:@[ @".*[rR]oad.*", @".*[mM]otorway.*" ]];

 

image

Map woodland layers

_

layers = currentStyle.getLayersBySourceLayerRegex("Woodland.*")
layers = [self.currentStyle getLayersBySourceLayerRegex:@"Woodland.*"];

 

image

Map No Build-Up layers

_

layers = currentStyle.getLayersBySourceLayerRegex("Built-up area")
layers = [self.currentStyle getLayersBySourceLayerRegex:@"Built-up area"];

 

You are here