Skip to content

Commit 238eada

Browse files
committed
[web] remove path if new marker selected and zoom to bounds
1 parent ea65361 commit 238eada

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

web/static/leaflet_script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ function setStart() {
4646
icon: greenIcon
4747
}).addTo(map);
4848
map.removeLayer(tmpMarker);
49+
if (typeof last_path === 'object') {
50+
map.removeLayer(last_path);
51+
}
4952
}
5053

5154
function setEnd() {
@@ -61,6 +64,9 @@ function setEnd() {
6164
icon: redIcon
6265
}).addTo(map);
6366
map.removeLayer(tmpMarker);
67+
if (typeof last_path === 'object') {
68+
map.removeLayer(last_path);
69+
}
6470
}
6571

6672
function query() {
@@ -122,6 +128,7 @@ function printPath(path) {
122128
});
123129
last_path = L.polyline(points);
124130
map.addLayer(last_path);
131+
map.fitBounds(last_path.getBounds().pad(Math.sqrt(2) / 4));
125132
}
126133

127134

0 commit comments

Comments
 (0)