X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/db675e706ad711014995e18d159c6deb0cc7fb44..66811558659c5b0e4b276e0be185e64a522846ff:/app/assets/javascripts/index/search.js diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index c32503e8e..b9e86a4c3 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -17,8 +17,8 @@ OSM.Search = function(map) { var div = $(this).parents(".search_more"); - div.find(".search_results_entry").hide(); - div.find(".search_searching").show(); + $(this).hide(); + div.find(".loader").show(); $.get($(this).attr("href"), function(data) { div.replaceWith(data); @@ -26,26 +26,20 @@ OSM.Search = function(map) { } function clickSearchResult(e) { - e.preventDefault(); - e.stopPropagation(); - var data = $(this).data(), center = L.latLng(data.lat, data.lon); + if (data.type && data.id) return; // Browse link + + e.preventDefault(); + e.stopPropagation(); + if (data.minLon && data.minLat && data.maxLon && data.maxLat) { map.fitBounds([[data.minLat, data.minLon], [data.maxLat, data.maxLon]]); } else { map.setView(center, data.zoom); } - - marker - .setLatLng(center) - .addTo(map); - - if (data.type && data.id) { - map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } }); - } } var marker = L.marker([0, 0], {icon: getUserIcon()});