Skip to content

Commit 123a4f3

Browse files
Added clipping boundary on the frontend
1 parent 560aa77 commit 123a4f3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

assets/js/map.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
$(document).ready(function () {
22
var result_geojson;
3+
var clipping_boundary;
34

45
window.onbeforeunload = function () {
56
return "Are you sure you want to leave? Think of your existing exports!";
@@ -166,6 +167,9 @@ $(document).ready(function () {
166167
if (map.hasLayer(resultVectorGrid)) {
167168
resultVectorGrid.remove();
168169
}
170+
if (map.hasLayer(clipping_boundary)) {
171+
clipping_boundary.remove();
172+
}
169173
}
170174

171175
function get_api_url() {
@@ -384,8 +388,16 @@ $(document).ready(function () {
384388
}
385389

386390
function fit_bounds_geojson(geojson) {
387-
var clippingBoundary = L.geoJson(geojson);
388-
var bounds = clippingBoundary.getBounds();
391+
clipping_boundary = L.geoJson(geojson, {
392+
style: {
393+
fillOpacity: 0,
394+
weight: 2,
395+
color: "#d6403f",
396+
interactive: false,
397+
},
398+
});
399+
clipping_boundary.addTo(map);
400+
var bounds = clipping_boundary.getBounds();
389401
var centroid = bounds.getCenter();
390402
var desiredZoomLevel = 18;
391403
map.setView(centroid, desiredZoomLevel);

0 commit comments

Comments
 (0)