diff --git a/src/ui/marker.js b/src/ui/marker.js index 809c4b6ebc7..85f4e366229 100644 --- a/src/ui/marker.js +++ b/src/ui/marker.js @@ -127,6 +127,12 @@ class Marker { element.appendChild(svg); // if no element and no offset option given apply an offset for the default marker + // -14 is used as the default marker offset since, the offset relative to center of the marker + // + // the marker tip is at the center of the shadow ellipse from the default svg + // the y value of the center of the shadow ellipse relative to the svg top left is "shadow transform translate-y (29.0) + ellipse cy (5.80029008)" + // offset to the svg center "height (41 / 2)" gives (29.0 + 5.80029008) - (41 / 2) and rounded for an integer pixel offset gives 14 + // negative is used to move the marker up from the center so the tip is at the Marker lngLat const defaultMarkerOffset = [0, -14]; if (!(options && options.offset)) { if (!options) {