Showing
2 changed files
with
26 additions
and
5 deletions
... | ... | @@ -131,10 +131,13 @@ export default abstract class LeafletMap { |
131 | 131 | tooltipAnchor: [16, -28], |
132 | 132 | shadowSize: [41, 41] |
133 | 133 | }); |
134 | + const customLatLng = this.convertToCustomFormat(mousePositionOnMap); | |
135 | + mousePositionOnMap.lat = customLatLng[this.options.latKeyName]; | |
136 | + mousePositionOnMap.lng = customLatLng[this.options.lngKeyName]; | |
137 | + | |
134 | 138 | const newMarker = L.marker(mousePositionOnMap, { icon }).addTo(this.map); |
135 | 139 | this.addMarkers.push(newMarker); |
136 | 140 | const datasourcesList = document.createElement('div'); |
137 | - const customLatLng = this.convertToCustomFormat(mousePositionOnMap); | |
138 | 141 | const header = document.createElement('p'); |
139 | 142 | header.appendChild(document.createTextNode('Select entity:')); |
140 | 143 | header.setAttribute('style', 'font-size: 14px; margin: 8px 0'); |
... | ... | @@ -415,7 +418,6 @@ export default abstract class LeafletMap { |
415 | 418 | }else if(position.lng < -180){ |
416 | 419 | position.lng = -180; |
417 | 420 | }; |
418 | - | |
419 | 421 | return { |
420 | 422 | [this.options.latKeyName]: position.lat, |
421 | 423 | [this.options.lngKeyName]: position.lng | ... | ... |
... | ... | @@ -258,10 +258,29 @@ export class ImageMap extends LeafletMap { |
258 | 258 | } |
259 | 259 | |
260 | 260 | convertToCustomFormat(position: L.LatLng, width = this.width, height = this.height): object { |
261 | - const point = this.latLngToPoint(position); | |
261 | + let point = this.latLngToPoint(position); | |
262 | + const customX = calculateNewPointCoordinate(point.x, width); | |
263 | + const customY = calculateNewPointCoordinate(point.y, height); | |
264 | + | |
265 | + if(customX === 0){ | |
266 | + point.x = 0; | |
267 | + } else if(customX === 1){ | |
268 | + point.x = width; | |
269 | + } | |
270 | + | |
271 | + if(customY === 0){ | |
272 | + point.y = 0; | |
273 | + } else if(customY === 1){ | |
274 | + point.y = height; | |
275 | + } | |
276 | + | |
277 | + const customLatLng = this.pointToLatLng(point.x,point.y) | |
278 | + | |
262 | 279 | return { |
263 | - [this.options.xPosKeyName]: calculateNewPointCoordinate(point.x, width), | |
264 | - [this.options.yPosKeyName]: calculateNewPointCoordinate(point.y, height) | |
280 | + [this.options.xPosKeyName]: customX, | |
281 | + [this.options.yPosKeyName]: customY, | |
282 | + [this.options.latKeyName]:customLatLng.lat, | |
283 | + [this.options.lngKeyName]:customLatLng.lng | |
265 | 284 | }; |
266 | 285 | } |
267 | 286 | ... | ... |