X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/c6cde2653b8dbcd3345348b33619b2240f1cc905..f5de157d2845ff1067b14604b2ca6c79ca7a7ac6:/app/assets/javascripts/index/search.js diff --git a/app/assets/javascripts/index/search.js b/app/assets/javascripts/index/search.js index 936cc1e0e..2f92e6282 100644 --- a/app/assets/javascripts/index/search.js +++ b/app/assets/javascripts/index/search.js @@ -1,5 +1,6 @@ function initializeSearch(map) { $("#search_form").submit(submitSearch); + $("#describe_location").click(describeLocation); if ($("#query").val()) { $("#search_form").submit(); @@ -30,6 +31,11 @@ function initializeSearch(map) { }); openSidebar(); + + $("#sidebar").one("closed", function () { + map.removeLayer(marker); + map.removeObject(); + }); } function clickSearchResult(e) { @@ -53,4 +59,18 @@ function initializeSearch(map) { map.addObject(data, { zoom: false, style: { opacity: 0.2, fill: false } }); } } + + function describeLocation(e) { + e.preventDefault(); + + var center = map.getCenter(), + zoom = map.getZoom(); + + $("#sidebar_title").html(I18n.t('site.sidebar.search_results')); + $("#sidebar_content").load($(this).attr("href"), { + lat: center.lat, + lon: center.lng, + zoom: zoom + }, openSidebar); + } }