Skip to content

Commit 6cd87dd

Browse files
committed
fix: parse coords
1 parent dcd6fde commit 6cd87dd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/vendors/Geo.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ function Geo(props) {
534534
if (!(featureEnabled('draw') &&
535535
(pdelete.getActive() || pmove.getActive() ||
536536
pedit.getActive() || ledit.getActive() || fedit.getActive()))
537-
&& layer && feature) { //only fire event if we are not drawing
537+
&& layer && layer.get("selectable") === true && feature) { //only fire event if we are not drawing
538538
fireEvent('click:feature', {
539539
extent: transformExtent(feature.getGeometry()?.extent_, 'EPSG:3857', 'EPSG:4326') || [],
540540
properties: feature.getProperties() || {},

src/vendors/helpers/Animate.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ import Zoom from 'ol-ext/featureanimation/Zoom'
1515
import { Point } from 'ol/geom'
1616
import * as easing from 'ol/easing';
1717

18+
export function parseCoords(coords) {
19+
if (!coords) return []
20+
try {
21+
if (typeof coords === 'string') coords = JSON.parse(coords)
22+
} catch (e) { }
23+
try {
24+
if (typeof coords === 'string') coords = JSON.parse("[" + coords + "]")
25+
} catch (e) { }
26+
if (Array.isArray(coords)) return coords
27+
if (coords.longitude) return [coords.longitude, coords.latitude]
28+
return coords
29+
}
30+
1831
export function animateToLocation(map, coords, duration, props = {}) {
1932
const location = fromLonLat(coords);
2033
return map.getView().animate(Object.assign({ zoom: 15 }, {
@@ -96,5 +109,5 @@ export const animations = {
96109

97110
export function animate(map, coords, duration = 2000, props = {}, name) {
98111
var func = animations[name || 'toLocation']
99-
if (func) func(map, coords, duration, props)
112+
if (func) func(map, parseCoords(coords), duration, props)
100113
}

0 commit comments

Comments
 (0)