From bd7a6ae5a724b6c23cb7f339c1ef7977662a779b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Jul 2015 11:35:06 +1200 Subject: Set default map position --- web/app/Resources.js | 6 ++++-- web/app/view/map/Map.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'web/app') diff --git a/web/app/Resources.js b/web/app/Resources.js index 446c59594..65c1e485f 100644 --- a/web/app/Resources.js +++ b/web/app/Resources.js @@ -26,8 +26,10 @@ var styles = { report_time: 100, report_format: 'Y-m-d H:i:s', - map_center: [ -0.1275, 51.507222 ], - map_zoom: 6, + map_default_lat: -0.1275, + map_default_lon: 51.507222, + map_default_zoom: 6, + map_max_zoom: 16, map_select_color: 'rgba(0, 255, 0, 1.0)', map_select_radius: 10, diff --git a/web/app/view/map/Map.js b/web/app/view/map/Map.js index b4fa8338f..57ecebe7d 100644 --- a/web/app/view/map/Map.js +++ b/web/app/view/map/Map.js @@ -30,8 +30,11 @@ Ext.define('Traccar.view.map.Map', { listeners: { afterrender: function() { + var user = Traccar.getApplication().getUser(); + var server = Traccar.getApplication().getServer(); + var layer; - var mapLayer = Traccar.getApplication().getUser().get('map') || Traccar.getApplication().getServer().get('map'); + var mapLayer = user.get('map') || server.get('map'); var bindKey = 'AseEs0DLJhLlTNoxbNXu7DGsnnH4UoWuGue7-irwKkE3fffaClwc9q_Mr6AyHY8F'; @@ -55,9 +58,13 @@ Ext.define('Traccar.view.map.Map', { source: this.vectorSource }); + var lat = user.get('latitude') || server.get('latitude') || styles.map_default_lat; + var lon = user.get('longitude') || server.get('longitude') || styles.map_default_lon; + var zoom = user.get('zoom') || server.get('zoom') || styles.map_default_zoom; + this.mapView = new ol.View({ - center: ol.proj.fromLonLat(styles.map_center), - zoom: styles.map_zoom, + center: ol.proj.fromLonLat([lat, lon]), + zoom: zoom, maxZoom: styles.map_max_zoom }); -- cgit v1.2.3