]> git.openstreetmap.org Git - rails.git/blob - app/assets/javascripts/maplibre/popup.js
Merge remote-tracking branch 'upstream/pull/7252'
[rails.git] / app / assets / javascripts / maplibre / popup.js
1 OSM.MapLibre.Popup = class extends maplibregl.Popup {
2   constructor(options) {
3     // General offset 5px for each side, but the offset depends on the popup position:
4     // Popup above the marker -> lift it by height + 5px = 45px
5     // Popup left the marker -> lift it by width/2 + 5px = 22.5px ~= 17px
6     const offset = {
7       "bottom": [0, -45],
8       "bottom-left": [0, -45],
9       "bottom-right": [0, -45],
10       "top": [0, 5],
11       "top-left": [0, 5],
12       "top-right": [0, 5],
13       // our marker is bigger at the top, but this does not attach there -> tucked 2px more
14       "right": [-15, -10],
15       "left": [15, -10]
16     };
17     super({ offset, ...options });
18   }
19 };