MapBox GL Marker in Wrong Location Unless Anchor Property Set to Top

185 Views Asked by At

The MapBox GL marker is placed at the wrong location unless the anchor property is set to top, which is annoying because now we have to setOffset so that the sharp end is pointing the actual location instead of simply using bottom. If anchor is set to bottom, the marker is nowhere to be found on the map.

const marker = new mapboxgl.Marker({
  anchor: 'top' // in right spot only if set to top
})
  .setLngLat([LNG, LAT])
    .addTo(map)
      .setOffset([0,-35]);

Does anybody know why this is happening?

0

There are 0 best solutions below