Reputation: 1237
I'm trying to toggle layers in iOS for MapBox but can't figure out how it's done. I've been looking at this example:
https://www.mapbox.com/mapbox.js/example/v1.0.0/layers/
But I can't figure out how to use this file with the map view in Xcode. Can anyone give me any info on how this is done? Or whether it's possible?
Just a bit of background on the setup, I have a mapview created and running fine. I then have numerous GPX trails which have been exported in to TileSets and added to a style as a layer. I have a layer called 'where_trail' which I want to toggle on and off with a button. Currently all the layers are drawing on the map, I just can't figure out how to access the layers and hide them. Can anyone offer me some guidance on this please?
Thanks
Upvotes: 0
Views: 439
Reputation: 11882
That example is for Mapbox.js and written in JavaScript: it's intended for use with our JavaScript framework, which, if you're in Swift, Objc, and Xcode, is not what you're using.
There isn't yet a full-fledged example of switching styles for the iOS framework, but the property to pay attention to is the styleURL - you can assign the value of that map property to a new NSURL, which you can get from Studio or from a default style. Wire this up to an action and it should do exactly what you're looking for.
Upvotes: 0