Browse Source

Fix marker move and marker point

pull/3705/head
Kalutka Zhenya 6 years ago
parent
commit
a06c835497
  1. 6
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 25
      ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts

6
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -131,10 +131,13 @@ export default abstract class LeafletMap {
tooltipAnchor: [16, -28], tooltipAnchor: [16, -28],
shadowSize: [41, 41] shadowSize: [41, 41]
}); });
const customLatLng = this.convertToCustomFormat(mousePositionOnMap);
mousePositionOnMap.lat = customLatLng[this.options.latKeyName];
mousePositionOnMap.lng = customLatLng[this.options.lngKeyName];
const newMarker = L.marker(mousePositionOnMap, { icon }).addTo(this.map); const newMarker = L.marker(mousePositionOnMap, { icon }).addTo(this.map);
this.addMarkers.push(newMarker); this.addMarkers.push(newMarker);
const datasourcesList = document.createElement('div'); const datasourcesList = document.createElement('div');
const customLatLng = this.convertToCustomFormat(mousePositionOnMap);
const header = document.createElement('p'); const header = document.createElement('p');
header.appendChild(document.createTextNode('Select entity:')); header.appendChild(document.createTextNode('Select entity:'));
header.setAttribute('style', 'font-size: 14px; margin: 8px 0'); header.setAttribute('style', 'font-size: 14px; margin: 8px 0');
@ -415,7 +418,6 @@ export default abstract class LeafletMap {
}else if(position.lng < -180){ }else if(position.lng < -180){
position.lng = -180; position.lng = -180;
}; };
return { return {
[this.options.latKeyName]: position.lat, [this.options.latKeyName]: position.lat,
[this.options.lngKeyName]: position.lng [this.options.lngKeyName]: position.lng

25
ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts

@ -258,10 +258,29 @@ export class ImageMap extends LeafletMap {
} }
convertToCustomFormat(position: L.LatLng, width = this.width, height = this.height): object { convertToCustomFormat(position: L.LatLng, width = this.width, height = this.height): object {
const point = this.latLngToPoint(position); let point = this.latLngToPoint(position);
const customX = calculateNewPointCoordinate(point.x, width);
const customY = calculateNewPointCoordinate(point.y, height);
if(customX === 0){
point.x = 0;
} else if(customX === 1){
point.x = width;
}
if(customY === 0){
point.y = 0;
} else if(customY === 1){
point.y = height;
}
const customLatLng = this.pointToLatLng(point.x,point.y)
return { return {
[this.options.xPosKeyName]: calculateNewPointCoordinate(point.x, width), [this.options.xPosKeyName]: customX,
[this.options.yPosKeyName]: calculateNewPointCoordinate(point.y, height) [this.options.yPosKeyName]: customY,
[this.options.latKeyName]:customLatLng.lat,
[this.options.lngKeyName]:customLatLng.lng
}; };
} }

Loading…
Cancel
Save