1 //= require leaflet.locate
3 $(document).ready(function () {
4 var map = L.map("map", {
5 attributionControl: false,
7 }).addLayer(new L.OSM.Mapnik());
9 var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
11 L.OSM.zoom({position: position})
17 title: I18n.t('javascripts.map.locate.title'),
18 popup: I18n.t('javascripts.map.locate.popup')
23 map.setView([OSM.home.lat, OSM.home.lon], 12);
25 map.setView([0, 0], 0);
28 if ($("#map").hasClass("set_location")) {
29 var marker = L.marker([0, 0], {icon: OSM.getUserIcon()});
32 marker.setLatLng([OSM.home.lat, OSM.home.lon]);
36 map.on("click", function (e) {
37 if ($('#updatehome').is(':checked')) {
38 var zoom = map.getZoom(),
39 precision = OSM.zoomPrecision(zoom),
40 location = e.latlng.wrap();
42 $('#homerow').removeClass();
43 $('#home_lat').val(location.lat.toFixed(precision));
44 $('#home_lon').val(location.lng.toFixed(precision));
46 marker.setLatLng(e.latlng);
51 $("[data-user]").each(function () {
52 var user = $(this).data('user');
53 if (user.lon && user.lat) {
54 L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
55 .bindPopup(user.description);