Refactoring

This commit is contained in:
Kalutka Zhenya 2021-01-14 19:28:56 +02:00
parent ac0a3fdf5c
commit 7f8c3ad0b3
2 changed files with 10 additions and 10 deletions

View File

@ -217,6 +217,7 @@ export default abstract class LeafletMap {
}); });
const dragListener = (e: L.DragEndEvent) => { const dragListener = (e: L.DragEndEvent) => {
if (e.type === 'dragend') {
const polygonOffset = this.options.provider === MapProviders.image ? 10 : 0.01; const polygonOffset = this.options.provider === MapProviders.image ? 10 : 0.01;
let convert = this.convertToCustomFormat(mousePositionOnMap,polygonOffset); let convert = this.convertToCustomFormat(mousePositionOnMap,polygonOffset);
@ -228,7 +229,6 @@ export default abstract class LeafletMap {
const latlng3 = L.latLng(mousePositionOnMap.lat - polygonOffset, mousePositionOnMap.lng); const latlng3 = L.latLng(mousePositionOnMap.lat - polygonOffset, mousePositionOnMap.lng);
polygonPoints = [latlng1, latlng2, latlng3]; polygonPoints = [latlng1, latlng2, latlng3];
if (e.type === 'dragend' && polygonPoints) {
const newPolygon = L.polygon(polygonPoints).addTo(this.map); const newPolygon = L.polygon(polygonPoints).addTo(this.map);
this.addPolygons.push(newPolygon); this.addPolygons.push(newPolygon);
const datasourcesList = document.createElement('div'); const datasourcesList = document.createElement('div');

View File

@ -192,7 +192,7 @@ export class ImageMap extends LeafletMap {
this.updateMarkers(this.markersData); this.updateMarkers(this.markersData);
if (this.options.draggableMarker && this.addMarkers.length) { if (this.options.draggableMarker && this.addMarkers.length) {
this.addMarkers.forEach((marker) => { this.addMarkers.forEach((marker) => {
const prevPoint = this.convertToCustomFormat(marker.getLatLng(),null, prevWidth, prevHeight); const prevPoint = this.convertToCustomFormat(marker.getLatLng(), null, prevWidth, prevHeight);
marker.setLatLng(this.convertPosition(prevPoint)); marker.setLatLng(this.convertPosition(prevPoint));
}); });
} }