From c4133052d79c82f30c53b60d9dda1b6d2972b4e2 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 21 Nov 2015 11:08:11 +1300 Subject: Split latest and report into two layers --- web/app/view/Map.js | 23 ++++++++++++++++------- web/app/view/MapController.js | 14 +++++++------- 2 files changed, 23 insertions(+), 14 deletions(-) (limited to 'web/app') diff --git a/web/app/view/Map.js b/web/app/view/Map.js index 7d81699a3..2db7d479d 100644 --- a/web/app/view/Map.js +++ b/web/app/view/Map.js @@ -35,13 +35,17 @@ Ext.define('Traccar.view.Map', { return this.mapView; }, - getVectorSource: function () { - return this.vectorSource; + getLatestSource: function () { + return this.latestSource; + }, + + getReportSource: function () { + return this.reportSource; }, listeners: { afterrender: function () { - var user, server, layer, type, bingKey, vectorLayer, lat, lon, zoom, target; + var user, server, layer, type, bingKey, latestLayer, reportLayer, lat, lon, zoom, target; user = Traccar.app.getUser(); server = Traccar.app.getServer(); @@ -78,9 +82,14 @@ Ext.define('Traccar.view.Map', { }); } - this.vectorSource = new ol.source.Vector({}); - vectorLayer = new ol.layer.Vector({ - source: this.vectorSource + this.latestSource = new ol.source.Vector({}); + latestLayer = new ol.layer.Vector({ + source: this.latestSource + }); + + this.reportSource = new ol.source.Vector({}); + reportLayer = new ol.layer.Vector({ + source: this.reportSource }); lat = user.get('latitude') || server.get('latitude') || Traccar.Style.mapDefaultLat; @@ -95,7 +104,7 @@ Ext.define('Traccar.view.Map', { this.map = new ol.Map({ target: this.body.dom.id, - layers: [layer, vectorLayer], + layers: [layer, latestLayer, reportLayer], view: this.mapView }); diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index 711bdadf9..3d86cc4ff 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -121,7 +121,7 @@ Ext.define('Traccar.view.MapController', { marker = new ol.Feature(geometry); marker.set('record', device); this.latestMarkers[deviceId] = marker; - this.getView().getVectorSource().addFeature(marker); + this.getView().getLatestSource().addFeature(marker); style = this.getLatestMarker(this.getDeviceColor(device)); style.getText().setText(device.get('name')); @@ -141,7 +141,7 @@ Ext.define('Traccar.view.MapController', { geometry: new ol.geom.LineString([]) }); this.reportRoute.setStyle(this.getRouteStyle()); - this.getView().getVectorSource().addFeature(this.reportRoute); + this.getView().getReportSource().addFeature(this.reportRoute); for (i = 0; i < data.length; i++) { position = data[i]; @@ -155,7 +155,7 @@ Ext.define('Traccar.view.MapController', { marker = new ol.Feature(geometry); marker.set('record', position); this.reportMarkers[position.get('id')] = marker; - this.getView().getVectorSource().addFeature(marker); + this.getView().getReportSource().addFeature(marker); style = this.getReportMarker(); style.getImage().setRotation(position.get('course') * Math.PI / 180); @@ -169,18 +169,18 @@ Ext.define('Traccar.view.MapController', { }, clearReport: function (store) { - var vectorSource, key; - vectorSource = this.getView().getVectorSource(); + var reportSource, key; + reportSource = this.getView().getReportSource(); if (this.reportRoute) { - vectorSource.removeFeature(this.reportRoute); + reportSource.removeFeature(this.reportRoute); this.reportRoute = null; } if (this.reportMarkers) { for (key in this.reportMarkers) { if (this.reportMarkers.hasOwnProperty(key)) { - vectorSource.removeFeature(this.reportMarkers[key]); + reportSource.removeFeature(this.reportMarkers[key]); } } this.reportMarkers = {}; -- cgit v1.2.3