Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add standard markers to Mapbox using addLayer()

Tags:

mapbox-gl-js

If you simply add a marker, you get a standard marker:

https://docs.mapbox.com/mapbox-gl-js/example/add-a-marker/

If you use addLayer() there appears to be no description anywhere about how to use these standard markers:

https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#symbol

map.addLayer({
    'id': 'POIs',
    'type': 'symbol',
    'source': 'POIs',
    'layout': {
        'icon-image': 'marker-15',  // this is a custom image... I just want a default, normal marker
        'icon-allow-overlap': true
    }
});

It's really easy to add special symbols, but I just want default markers. How do I do this with addLayer()

like image 216
Seph Reed Avatar asked Oct 22 '25 09:10

Seph Reed


1 Answers

Hugely disappointing news. Somehow it's just not possible:

https://github.com/mapbox/mapbox-gl-js/issues/656

I guess you just have to iterate over whatever your data is and use addMarker() for each.

like image 100
Seph Reed Avatar answered Oct 24 '25 04:10

Seph Reed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!