Skip to content

Commit

Permalink
closes #1326, fixes snapping on map with and without circle (#1338)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuchQuak authored May 17, 2024
1 parent 288e43f commit 00eda61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions collections/tools/mappointaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function leafletInit() {
map = new LeafletMap('map_canvas', {
center: [latCenter, lngCenter],
zoom: 7,
lang: "<?php echo $LANG_TAG; ?>"
lang: "<?php echo $LANG_TAG; ?>"
});

var drawnItems = new L.FeatureGroup();
Expand Down Expand Up @@ -127,7 +127,7 @@ function createMarker(lat, lng) {

if(errRadius && errRadius > 0) {
marker.addTo(map.mapLayer);
L.circle([lat, lng], errRadius)
const circ = L.circle([lat, lng], errRadius)
.on('drag', e=> {
const pos = e.target.getLatLng()

Expand All @@ -140,6 +140,8 @@ function createMarker(lat, lng) {
.setStyle(map.DEFAULT_SHAPE_OPTIONS)
.addTo(drawnItems);

map.mapLayer.fitBounds(circ.getBounds());

map.mapLayer.on('draw:deleted', e => {
map.mapLayer.removeLayer(marker);
})
Expand Down Expand Up @@ -208,7 +210,7 @@ function createMarker(lat, lng) {
})

//Draw marker if one exists
if(latlng) {
if(latlng) {
createMarker(latlng[0], latlng[1]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/symb/leafletMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class LeafletMap {
constructor(map_id, map_options={}) {

map_options = {
...map_options,
...this.DEFAULT_MAP_OPTIONS,
...map_options,
}

this.mapLayer = L.map(map_id, map_options);
Expand Down

0 comments on commit 00eda61

Please sign in to comment.