1 $(document).ready(function () {
4 function setLocation(e) {
5 const latlng = e.latlng.wrap();
7 $("#latitude").val(latlng.lat);
8 $("#longitude").val(latlng.lng);
11 map.removeLayer(marker);
14 marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map)
15 .bindPopup(I18n.t("diary_entries.edit.marker_text"));
18 $("#usemap").click(function (e) {
24 var params = $("#map").data();
25 var centre = [params.lat, params.lon];
26 var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
29 attributionControl: false,
31 }).addLayer(new L.OSM.Mapnik());
33 L.OSM.zoom({ position: position })
36 map.setView(centre, params.zoom);
38 if ($("#latitude").val() && $("#longitude").val()) {
39 marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map)
40 .bindPopup(I18n.t("diary_entries.edit.marker_text"));
43 map.on("click", setLocation);