diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-12-02 18:46:55 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-02 18:46:55 +1300 |
commit | f8bf7ede29f2e063a30721e8ed415a6184646424 (patch) | |
tree | 43259e48230270edaed0a1981e8ef975508c9831 /web/app/view/MapMarkerController.js | |
parent | 6d447219ceab19c368b7ca6efabca83001b64a04 (diff) | |
parent | ea09b2e85e014d438084a454fae7c0cce57d9773 (diff) | |
download | trackermap-web-f8bf7ede29f2e063a30721e8ed415a6184646424.tar.gz trackermap-web-f8bf7ede29f2e063a30721e8ed415a6184646424.tar.bz2 trackermap-web-f8bf7ede29f2e063a30721e8ed415a6184646424.zip |
Merge pull request #347 from Abyss777/handle_eventid
Handle eventId url parameter
Diffstat (limited to 'web/app/view/MapMarkerController.js')
-rw-r--r-- | web/app/view/MapMarkerController.js | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index 97e75925..5fa9f4ca 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -202,30 +202,26 @@ Ext.define('Traccar.view.MapMarkerController', { this.addReportMarkers(store, data); - if (data.length > 0) { - this.reportRoute = []; - for (i = 0; i < data.length; i++) { - position = data[i]; - point = ol.proj.fromLonLat([ - position.get('longitude'), - position.get('latitude') - ]); - if (i === 0 || data[i].get('deviceId') !== data[i - 1].get('deviceId')) { - this.reportRoute.push(new ol.Feature({ - geometry: new ol.geom.LineString([]) - })); - this.reportRoute[this.reportRoute.length - 1].setStyle(this.getRouteStyle(data[i].get('deviceId'))); - this.getView().getRouteSource().addFeature(this.reportRoute[this.reportRoute.length - 1]); - } - this.reportRoute[this.reportRoute.length - 1].getGeometry().appendCoordinate(point); + this.reportRoute = []; + for (i = 0; i < data.length; i++) { + position = data[i]; + point = ol.proj.fromLonLat([ + position.get('longitude'), + position.get('latitude') + ]); + if (i === 0 || data[i].get('deviceId') !== data[i - 1].get('deviceId')) { + this.reportRoute.push(new ol.Feature({ + geometry: new ol.geom.LineString([]) + })); + this.reportRoute[this.reportRoute.length - 1].setStyle(this.getRouteStyle(data[i].get('deviceId'))); + this.getView().getRouteSource().addFeature(this.reportRoute[this.reportRoute.length - 1]); } - - this.getView().getMapView().fit(this.reportRoute[0].getGeometry(), this.getView().getMap().getSize()); + this.reportRoute[this.reportRoute.length - 1].getGeometry().appendCoordinate(point); } }, addReportMarkers: function (store, data) { - var i, position, point, geometry, marker, style; + var i, position, point, geometry, marker, style, minx, miny, maxx, maxy; this.clearReport(); for (i = 0; i < data.length; i++) { position = data[i]; @@ -233,6 +229,15 @@ Ext.define('Traccar.view.MapMarkerController', { position.get('longitude'), position.get('latitude') ]); + if (i === 0) { + minx = maxx = point[0]; + miny = maxy = point[1]; + } else { + minx = Math.min(point[0], minx); + miny = Math.min(point[1], miny); + maxx = Math.max(point[0], maxx); + maxy = Math.max(point[1], maxy); + } geometry = new ol.geom.Point(point); marker = new ol.Feature(geometry); marker.set('record', position); @@ -243,6 +248,11 @@ Ext.define('Traccar.view.MapMarkerController', { this.reportMarkers[position.get('id')] = marker; this.getView().getReportSource().addFeature(marker); } + if (minx !== maxx || miny !== maxy) { + this.getView().getMapView().fit([minx, miny, maxx, maxy], this.getView().getMap().getSize()); + } else if (geometry) { + this.getView().getMapView().fit(geometry, this.getView().getMap().getSize()); + } }, clearReport: function () { |