aboutsummaryrefslogtreecommitdiff
path: root/web/app/controller/Root.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-15 23:08:57 +1300
committerGitHub <noreply@github.com>2017-03-15 23:08:57 +1300
commitfd2207b15d98d8fdef306f3b94924a759c80a3d9 (patch)
treea50b36f4f3c5da83f8a13955331a4688c75e96b5 /web/app/controller/Root.js
parentd77cc1c9b2890224119d59b493597e47e3f1792f (diff)
parent7135682a0f262dc4b76f41bec2db4c022f88b17b (diff)
downloadtrackermap-web-fd2207b15d98d8fdef306f3b94924a759c80a3d9.tar.gz
trackermap-web-fd2207b15d98d8fdef306f3b94924a759c80a3d9.tar.bz2
trackermap-web-fd2207b15d98d8fdef306f3b94924a759c80a3d9.zip
Merge pull request #440 from Abyss777/zoom_to_all
Zoom to all devices on start
Diffstat (limited to 'web/app/controller/Root.js')
-rw-r--r--web/app/controller/Root.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js
index 404fb7cc..b6e5f385 100644
--- a/web/app/controller/Root.js
+++ b/web/app/controller/Root.js
@@ -161,7 +161,8 @@ Ext.define('Traccar.controller.Root', {
self.updateDevices(data.devices);
}
if (data.positions) {
- self.updatePositions(data.positions);
+ self.updatePositions(data.positions, first);
+ first = false;
}
if (data.events) {
self.updateEvents(data.events);
@@ -185,7 +186,7 @@ Ext.define('Traccar.controller.Root', {
}
},
- updatePositions: function (array) {
+ updatePositions: function (array, first) {
var i, store, entity;
store = Ext.getStore('LatestPositions');
for (i = 0; i < array.length; i++) {
@@ -196,6 +197,9 @@ Ext.define('Traccar.controller.Root', {
store.add(Ext.create('Traccar.model.Position', array[i]));
}
}
+ if (first) {
+ this.zoomToAllDevices();
+ }
},
updateEvents: function (array) {
@@ -225,5 +229,15 @@ Ext.define('Traccar.controller.Root', {
Ext.toast(text, device.get('name'), 'br');
}
}
+ },
+
+ zoomToAllDevices: function () {
+ var lat, lon, zoom;
+ lat = Traccar.app.getPreference('latitude', 0);
+ lon = Traccar.app.getPreference('longitude', 0);
+ zoom = Traccar.app.getPreference('zoom', 0);
+ if (lat === 0 && lon === 0 && zoom === 0) {
+ this.fireEvent('zoomtoalldevices');
+ }
}
});