1 //= require maplibre.map
2 //= require maplibre.i18n
3 //= require maplibre.combinedcontrolgroup
6 const defaultHomeZoom = 11;
9 if ($("#map").length) {
10 map = new maplibregl.Map({
12 style: OSM.MapLibre.Styles.Mapnik,
13 attributionControl: false,
14 locale: OSM.MapLibre.Locale,
15 center: OSM.home ? [OSM.home.lon, OSM.home.lat] : [0, 0],
16 zoom: OSM.home ? defaultHomeZoom : 0
19 const position = $("html").attr("dir") === "rtl" ? "top-left" : "top-right";
20 const navigationControl = new maplibregl.NavigationControl({ showCompass: false });
21 const geolocateControl = new maplibregl.GeolocateControl({
23 enableHighAccuracy: true
25 trackUserLocation: true
27 map.addControl(new OSM.MapLibre.CombinedControlGroup([navigationControl, geolocateControl]), position);
29 $("[data-user]").each(function () {
30 const user = $(this).data("user");
31 if (user.lon && user.lat) {
32 OSM.MapLibre.getMarker({ icon: "dot", color: user.color })
33 .setLngLat([user.lon, user.lat])
34 .setPopup(OSM.MapLibre.getPopup(user.description))