From 8763594f66474464367af2b699bf70d840f31207 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 19 Apr 2017 17:30:25 +0500 Subject: Check feature existence before delete --- web/app/view/map/MapMarkerController.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/web/app/view/map/MapMarkerController.js b/web/app/view/map/MapMarkerController.js index 9dcb356..44067dc 100644 --- a/web/app/view/map/MapMarkerController.js +++ b/web/app/view/map/MapMarkerController.js @@ -157,15 +157,21 @@ Ext.define('Traccar.view.map.MapMarkerController', { for (i = 0; i < data.length; i++) { deviceId = data[i].get('id'); if (this.latestMarkers[deviceId]) { - this.getView().getMarkersSource().removeFeature(this.latestMarkers[deviceId]); + if (this.getView().getMarkersSource().getFeatureById(this.latestMarkers[deviceId].getId())) { + this.getView().getMarkersSource().removeFeature(this.latestMarkers[deviceId]); + } delete this.latestMarkers[deviceId]; } if (this.accuracyCircles[deviceId]) { - this.getView().getAccuracySource().removeFeature(this.accuracyCircles[deviceId]); + if (this.getView().getAccuracySource().getFeatureById(this.accuracyCircles[deviceId].getId())) { + this.getView().getAccuracySource().removeFeature(this.accuracyCircles[deviceId]); + } delete this.accuracyCircles[deviceId]; } if (this.liveRoutes[deviceId]) { - this.getView().getLiveRouteSource().removeFeature(this.liveRoutes[deviceId]); + if (this.getView().getLiveRouteSource().getFeatureById(this.liveRoutes[deviceId].getId())) { + this.getView().getLiveRouteSource().removeFeature(this.liveRoutes[deviceId]); + } delete this.liveRoutes[deviceId]; } } @@ -282,7 +288,7 @@ Ext.define('Traccar.view.map.MapMarkerController', { ]) }); liveLine.setStyle(this.getRouteStyle(deviceId)); - liveLine.setId(position.get('deviceId')); + liveLine.setId(deviceId); this.liveRoutes[deviceId] = liveLine; if (this.isDeviceVisible(device)) { this.getView().getMarkersSource().addFeature(liveLine); -- cgit v1.2.3