From b93d36f154d6e5b16769ddec07bb8936512f8bb1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 15 Mar 2017 09:38:12 +0500 Subject: Zoom to all devices on launch --- web/app/controller/Root.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'web/app/controller/Root.js') diff --git a/web/app/controller/Root.js b/web/app/controller/Root.js index 404fb7cc..94f0705f 100644 --- a/web/app/controller/Root.js +++ b/web/app/controller/Root.js @@ -167,6 +167,9 @@ Ext.define('Traccar.controller.Root', { self.updateEvents(data.events); } }; + if (first) { + this.first = true; + } }, updateDevices: function (array) { @@ -196,6 +199,10 @@ Ext.define('Traccar.controller.Root', { store.add(Ext.create('Traccar.model.Position', array[i])); } } + if (this.first) { + this.zoomToAllDevices(); + this.first = false; + } }, updateEvents: function (array) { @@ -225,5 +232,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'); + } } }); -- cgit v1.2.3