1 $(document).ready(function () {
4 function setLocation(e) {
5 $("#latitude").val(e.latlng.lat);
6 $("#longitude").val(e.latlng.lng);
9 map.removeLayer(marker);
12 marker = L.marker(e.latlng, { icon: OSM.getUserIcon() }).addTo(map)
13 .bindPopup(I18n.t("diary_entries.edit.marker_text"));
16 $("#usemap").click(function (e) {
22 var params = $("#map").data();
23 var centre = [params.lat, params.lon];
24 var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
27 attributionControl: false,
29 }).addLayer(new L.OSM.Mapnik());
31 L.OSM.zoom({ position: position })
34 map.setView(centre, params.zoom);
36 if ($("#latitude").val() && $("#longitude").val()) {
37 marker = L.marker(centre, { icon: OSM.getUserIcon() }).addTo(map)
38 .bindPopup(I18n.t("diary_entries.edit.marker_text"));
41 map.on("click", setLocation);