Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add layers with mapbox-gl-js custom markers?

Tags:

mapbox-gl-js

I'm trying to create custom markers, but add 2 map layers.

Essentially trying to combine this: https://www.mapbox.com/mapbox-gl-js/example/custom-marker-icons/

With this: https://www.mapbox.com/mapbox-gl-js/example/toggle-layers/

How do I specify my customized markers, but assign them to 2 layers?

like image 249
Justin Young Avatar asked Oct 17 '22 02:10

Justin Young


1 Answers

Markers don't exist within the map's Style, so they don't live within Layers either. They sit on top of the map, effectively within a single "layer" (but not actually a Layer).

So if you're trying to find a way to hide or show groups of markers in a single action, you'll have to find another way to do that.

Alternatively, if you really want your markers within Layers, you should create Symbol Layers with icons, not markers.

like image 157
Steve Bennett Avatar answered Oct 21 '22 04:10

Steve Bennett