From 302bbba7cfc04b0bc90fff9279c587545a9816c4 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Thu, 20 Feb 2020 19:19:48 +0100 Subject: [PATCH] when &viewbox was set in URL display a green rectangle on map --- src/assets/js/searchpage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/assets/js/searchpage.js b/src/assets/js/searchpage.js index 81ecbd7..b970afc 100755 --- a/src/assets/js/searchpage.js +++ b/src/assets/js/searchpage.js @@ -73,6 +73,14 @@ function init_map_on_search_page(is_reverse_search, nominatim_results, request_l } ); cm.addTo(map); + } else { + var search_params = new URLSearchParams(location.search); + var viewbox = search_params.get('viewbox'); + if (viewbox) { + var coords = viewbox.split(','); // ,,, + var bounds = L.latLngBounds([coords[1], coords[0]], [coords[3], coords[2]]); + L.rectangle(bounds, {color: "#69d53e", weight: 3, dashArray: '5 5', opacity: 0.8, fill: false}).addTo(map); + } } var MapPositionControl = L.Control.extend({ @@ -342,7 +350,7 @@ jQuery(document).ready(function () { var context = { // aSearchResults: aResults, sQuery: api_request_params.q, - sViewBox: '', + sViewBox: search_params.get('viewbox'), env: Nominatim_Config, sMoreURL: '' }; -- 2.39.5