We rolled out a new and better SDK for you.

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 this 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, and Default style.

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


Map Road network layers

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


Map woodland layers

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


Map No Build-Up layers

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