aboutsummaryrefslogtreecommitdiff
path: root/web/app
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-08 22:42:57 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-08 22:42:57 +1300
commit18ec7e54839430503b5a73cbf2e63dfa2e234e7b (patch)
tree94187a565de86c759ec14874b172736c5b0b4338 /web/app
parent8cd4f224572e55cd3c87119db24b8adcf1f0351a (diff)
downloadtrackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.tar.gz
trackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.tar.bz2
trackermap-server-18ec7e54839430503b5a73cbf2e63dfa2e234e7b.zip
Do not display unknown devices
Diffstat (limited to 'web/app')
-rw-r--r--web/app/view/MapController.js44
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());
+ }
}
}
},