Search code examples
mapboxmapbox-gl-jsmapbox-glmapbox-marker

Multiple markers - Same coordinates


I'm having some troubles trying to display 2 different markers placed at exactly the same coordinates.

The case is: we are displaying stores, and some of them are placed at the same building (ie. a mall), so, they are different stores but shares the same ubication/coordinates.

Our json source content looks like this:

  {
     "properties" : {
        "id" : "1",
        "name" : "Store 1"
     },
     "geometry" : {
        "coordinates" : [-70.66667, -33.45],
        "type" : "Point"
     }
  },
  {
     "properties" : {
        "id" : "2",
        "name" : "Store 2"
     },
     "geometry" : {
        "coordinates" : [-70.66667, -33.45],
        "type" : "Point"
     }
  }

The thing is, just one of them gets displayed.

My question is, is there an out of the box solution for this use-case? Or should we implement our own solution ?

Thanks in advance!


Solution

  • If you are using the Marker class from mapbox-gl, you can just apply standard CSS transform to offset the marker.

    Another solution would be something refered to as "spider marker":