1 //= require leaflet.locate
3 $(document).ready(function () {
4 var map = L.map("map", {
5 attributionControl: false,
7 }).addLayer(new L.OSM.Mapnik());
14 title: I18n.t('javascripts.map.locate.title'),
15 popup: I18n.t('javascripts.map.locate.popup')
20 map.setView([OSM.home.lat, OSM.home.lon], 12);
22 map.setView([0, 0], 0);
25 if ($("#map").hasClass("set_location")) {
26 var marker = L.marker([0, 0], {icon: getUserIcon()});
29 marker.setLatLng([OSM.home.lat, OSM.home.lon]);
33 map.on("click", function (e) {
34 if ($('#updatehome').is(':checked')) {
35 var zoom = map.getZoom(),
36 precision = zoomPrecision(zoom),
37 location = e.latlng.wrap();
39 $('#homerow').removeClass();
40 $('#home_lat').val(location.lat.toFixed(precision));
41 $('#home_lon').val(location.lng.toFixed(precision));
43 marker.setLatLng(e.latlng);
48 $("[data-user]").each(function () {
49 var user = $(this).data('user');
50 if (user.lon && user.lat) {
51 L.marker([user.lat, user.lon], {icon: getUserIcon(user.icon)}).addTo(map)
52 .bindPopup(user.description);