1

When reading examples of Mapbox GL using custom markers, I've seen examples - ie: https://www.mapbox.com/mapbox-gl-js/example/geojson-markers/ where geojson data is hard coded (geometry) and icons can be custom selected for the map...

In a quick example that I've created : https://jsfiddle.net/claybox7/cmh3qw22/8/ I'm using a 'vector' geometry source saved in mapbox . When it is run, it will show circles of the provided long/lat from my data source.

How would I create markers like the "icon": "monument" ones used in the mapbox gl example above instead of circles to represent my geometry points?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 19, 2016 at 21:40

1 Answer 1

4

You need to change the type of your layer from circle to symbol and add an icon-image at the layout properties. The code should look like this:

map.addLayer({
 'id': 'schoolData',
 'type': 'symbol',
 'source': 'schoolData',
 'layout': {
 'visibility': 'visible',
 'icon-image': 'monument-15'
 }, ...
});

All possible default icons can be found at Github.

answered Sep 20, 2016 at 5:30
1
  • Excellent! Thanks! - Here's the updated jsfiddle example: jsfiddle.net/cmh3qw22/9 Commented Sep 20, 2016 at 7:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.