Skip to content

Commit

Permalink
Added clipping boundary on the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Nov 22, 2024
1 parent 560aa77 commit 123a4f3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions assets/js/map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$(document).ready(function () {
var result_geojson;
var clipping_boundary;

window.onbeforeunload = function () {
return "Are you sure you want to leave? Think of your existing exports!";
Expand Down Expand Up @@ -166,6 +167,9 @@ $(document).ready(function () {
if (map.hasLayer(resultVectorGrid)) {
resultVectorGrid.remove();
}
if (map.hasLayer(clipping_boundary)) {
clipping_boundary.remove();
}
}

function get_api_url() {
Expand Down Expand Up @@ -384,8 +388,16 @@ $(document).ready(function () {
}

function fit_bounds_geojson(geojson) {
var clippingBoundary = L.geoJson(geojson);
var bounds = clippingBoundary.getBounds();
clipping_boundary = L.geoJson(geojson, {
style: {
fillOpacity: 0,
weight: 2,
color: "#d6403f",
interactive: false,
},
});
clipping_boundary.addTo(map);
var bounds = clipping_boundary.getBounds();
var centroid = bounds.getCenter();
var desiredZoomLevel = 18;
map.setView(centroid, desiredZoomLevel);
Expand Down

0 comments on commit 123a4f3

Please sign in to comment.