1

I'm trying to display a clustered map with Mapbox GL JS.

Using this example from the documentation: https://www.mapbox.com/mapbox-gl-js/example/cluster/, I'd like to show a marker icon instead of a circle for unclustered points.

I modified the last addLayer call like this :

map.addLayer({
    id: "unclustered-point",
    type: "symbol",
    source: "companies",
    filter: ["!has", "point_count"],
    layout: {
        "icon-image": "marker-15", // THIS SHOULD BE A MARKER
        "icon-size": 5 // ZOOMED FOR DEMO
    },
});

Here is the result I got :

enter image description here

Why can't I get access to Maki Icons like it is suggested here : Mapbox GL js available icons

Thomas Milan
  • 289
  • 1
  • 5
  • 14

1 Answers1

1

Without a link to your (non) working example, it's hard to diagnose fully, but one possibility is that that icon is not included in your style.

You could try starting from a style that definitely includes them, like these: https://github.com/mapbox/mapbox-gl-styles

Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
  • Thanks for your answer Steve. I looked at the sprites loaded with the style `streets-v10` which is the one I use (sorry I forgot to mention that). And indeed, the marker icon I want to use is not a part of it. However, I'd still like to use or `streets-v9` or `streets-v10` styles. Should I load a different sprite sheet when creating my map using a style object instead of an url pointing to `streets-v10` ? – Thomas Milan Jun 28 '18 at 07:58
  • Easiest is probably to just add the icon to the style you want, using Studio. – Steve Bennett Jun 28 '18 at 08:27
  • I ended up adding a custom marker image from a local folder as shown in the documentation here : https://www.mapbox.com/mapbox-gl-js/example/add-image/ But you were right, the marker image I wanted was missing from the original style ! – Thomas Milan Jun 28 '18 at 13:06