X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/dd1ec4eb9bd23c2e7d93451b41f3eda99ffb9f08..5cb9f2b022ba1c829ae5f4d980f27c7aad694ff6:/app/assets/javascripts/user.js?ds=sidebyside diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index 97827fb8d..77cb86a8d 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -1,25 +1,26 @@ -function init(){ - var params = $("#map").data(); +$(document).ready(function () { var map = createMap("map"); - setMapCenter(new OpenLayers.LonLat(params.lon, params.lat), params.zoom); + if (OSM.home) { + setMapCenter(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat), 12); + } else { + setMapCenter(new OpenLayers.LonLat(0, 0), 0); + } if ($("#map").hasClass("set_location")) { var marker; - if (params.marker) { - marker = addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat)); + if (OSM.home) { + marker = addMarkerToMap(new OpenLayers.LonLat(OSM.home.lon, OSM.home.lat)); } map.events.register("click", map, function (e) { - closeMapPopup(); - - if (document.getElementById('updatehome').checked) { + if ($('#updatehome').is(':checked')) { var lonlat = getEventPosition(e); - document.getElementById('homerow').className = ''; - document.getElementById('home_lat').value = lonlat.lat; - document.getElementById('home_lon').value = lonlat.lon; + $('#homerow').removeClass(); + $('#home_lat').val(lonlat.lat); + $('#home_lon').val(lonlat.lon); if (marker) { removeMarkerFromMap(marker); @@ -29,8 +30,6 @@ function init(){ } }); } else { - addMarkerToMap(new OpenLayers.LonLat(params.lon, params.lat), null, params.marker.description); - $("[data-user]").each(function () { var user = $(this).data('user'); if (user.lon && user.lat) { @@ -40,6 +39,4 @@ function init(){ } }); } -} - -window.onload = init; +});