From e488a104b434cf0b0addd51f129d5bf6074833a3 Mon Sep 17 00:00:00 2001 From: liryyy Date: Sat, 29 Oct 2022 13:56:42 +1300 Subject: [PATCH] Add polygon to searched country/state --- examples/js/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/js/index.js b/examples/js/index.js index bfea75aec..374d2694b 100644 --- a/examples/js/index.js +++ b/examples/js/index.js @@ -12,4 +12,17 @@ let map; }); })(); -L.Control.geocoder().addTo(map); +var geocoder = L.Control.geocoder({ + defaultMarkGeocode: true +}) +.on('markgeocode', function(e){ + var bbox = e.geocode.bbox; + var poly = L.polygon([ + bbox.getSouthEast(), + bbox.getNorthEast(), + bbox.getNorthWest(), + bbox.getSouthWest() + ]).addTo(map); + map.fitBounds(poly.getBounds()); +}) +.addTo(map); \ No newline at end of file