diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-08 22:42:57 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-03-08 22:42:57 +1300 |
commit | 18ec7e54839430503b5a73cbf2e63dfa2e234e7b (patch) | |
tree | 94187a565de86c759ec14874b172736c5b0b4338 | |
parent | 8cd4f224572e55cd3c87119db24b8adcf1f0351a (diff) | |
download | trackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.tar.gz trackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.tar.bz2 trackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.zip |
Do not display unknown devices
-rw-r--r-- | web/app/view/MapController.js | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index ce420c2ec..918f81390 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -113,29 +113,31 @@ Ext.define('Traccar.view.MapController', { deviceId = position.get('deviceId'); device = Ext.getStore('Devices').findRecord('id', deviceId, 0, false, false, true); - geometry = new ol.geom.Point(ol.proj.fromLonLat([ - position.get('longitude'), - position.get('latitude') - ])); - - if (deviceId in this.latestMarkers) { - marker = this.latestMarkers[deviceId]; - marker.setGeometry(geometry); - } else { - marker = new ol.Feature(geometry); - marker.set('record', device); - this.latestMarkers[deviceId] = marker; - this.getView().getLatestSource().addFeature(marker); - - style = this.getLatestMarker(this.getDeviceColor(device)); - style.getText().setText(device.get('name')); - marker.setStyle(style); - } + if (device) { + geometry = new ol.geom.Point(ol.proj.fromLonLat([ + position.get('longitude'), + position.get('latitude') + ])); + + if (deviceId in this.latestMarkers) { + marker = this.latestMarkers[deviceId]; + marker.setGeometry(geometry); + } else { + marker = new ol.Feature(geometry); + marker.set('record', device); + this.latestMarkers[deviceId] = marker; + this.getView().getLatestSource().addFeature(marker); + + style = this.getLatestMarker(this.getDeviceColor(device)); + style.getText().setText(device.get('name')); + marker.setStyle(style); + } - marker.getStyle().getImage().setRotation(position.get('course') * Math.PI / 180); + marker.getStyle().getImage().setRotation(position.get('course') * Math.PI / 180); - if (marker === this.selectedMarker && this.followSelected()) { - this.getView().getMapView().setCenter(marker.getGeometry().getCoordinates()); + if (marker === this.selectedMarker && this.followSelected()) { + this.getView().getMapView().setCenter(marker.getGeometry().getCoordinates()); + } } } }, |