aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/Map.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view/Map.js')
-rw-r--r--web/app/view/Map.js123
1 files changed, 67 insertions, 56 deletions
diff --git a/web/app/view/Map.js b/web/app/view/Map.js
index f7a763b9d..e356c4678 100644
--- a/web/app/view/Map.js
+++ b/web/app/view/Map.js
@@ -13,73 +13,84 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+(function () {
+ 'use strict';
-Ext.define('Traccar.view.Map', {
- extend: 'Ext.form.Panel',
- xtype: 'mapView',
+ Ext.define('Traccar.view.Map', {
+ extend: 'Ext.form.Panel',
+ xtype: 'mapView',
- requires: [
- 'Traccar.view.MapController'
- ],
+ requires: [
+ 'Traccar.view.MapController'
+ ],
- controller: 'map',
+ controller: 'map',
- title: strings.mapTitle,
- layout: 'fit',
+ title: strings.mapTitle,
+ layout: 'fit',
- listeners: {
- afterrender: function () {
- var user = Traccar.app.getUser();
- var server = Traccar.app.getServer();
+ listeners: {
+ afterrender: function () {
+ var user = Traccar.app.getUser();
+ var server = Traccar.app.getServer();
- var layer;
- var mapLayer = user.get('map') || server.get('map');
+ var layer;
+ var mapLayer = user.get('map') || server.get('map');
- var bingKey = server.get('bingKey');
+ var bingKey = server.get('bingKey');
- if (mapLayer === 'custom') {
- layer = new ol.layer.Tile({ source: new ol.source.XYZ({
- url: server.get('mapUrl')
- })});
- } else if (mapLayer === 'bingRoad') {
- layer = new ol.layer.Tile({ source: new ol.source.BingMaps({
- key: bingKey,
- imagerySet: 'Road'
- })});
- } else if (mapLayer === 'bingAerial') {
- layer = new ol.layer.Tile({ source: new ol.source.BingMaps({
- key: bingKey,
- imagerySet: 'Aerial'
- })});
- } else {
- layer = new ol.layer.Tile({ source: new ol.source.OSM({
- })});
- }
+ if (mapLayer === 'custom') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.XYZ({
+ url: server.get('mapUrl')
+ })
+ });
+ } else if (mapLayer === 'bingRoad') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.BingMaps({
+ key: bingKey,
+ imagerySet: 'Road'
+ })
+ });
+ } else if (mapLayer === 'bingAerial') {
+ layer = new ol.layer.Tile({
+ source: new ol.source.BingMaps({
+ key: bingKey,
+ imagerySet: 'Aerial'
+ })
+ });
+ } else {
+ layer = new ol.layer.Tile({
+ source: new ol.source.OSM({})
+ });
+ }
- this.vectorSource = new ol.source.Vector({});
- var vectorLayer = new ol.layer.Vector({
- source: this.vectorSource
- });
+ this.vectorSource = new ol.source.Vector({});
+ var vectorLayer = new ol.layer.Vector({
+ source: this.vectorSource
+ });
- var lat = user.get('latitude') || server.get('latitude') || styles.mapDefaultLat;
- var lon = user.get('longitude') || server.get('longitude') || styles.mapDefaultLon;
- var zoom = user.get('zoom') || server.get('zoom') || styles.mapDefaultZoom;
+ var lat = user.get('latitude') || server.get('latitude') || styles.mapDefaultLat;
+ var lon = user.get('longitude') || server.get('longitude') || styles.mapDefaultLon;
+ var zoom = user.get('zoom') || server.get('zoom') || styles.mapDefaultZoom;
- this.mapView = new ol.View({
- center: ol.proj.fromLonLat([lon, lat]),
- zoom: zoom,
- maxZoom: styles.mapMaxZoom
- });
+ this.mapView = new ol.View({
+ center: ol.proj.fromLonLat([lon, lat]),
+ zoom: zoom,
+ maxZoom: styles.mapMaxZoom
+ });
- this.map = new ol.Map({
- target: this.body.dom.id,
- layers: [layer, vectorLayer],
- view: this.mapView
- });
- },
+ this.map = new ol.Map({
+ target: this.body.dom.id,
+ layers: [layer, vectorLayer],
+ view: this.mapView
+ });
+ },
- resize: function () {
- this.map.updateSize();
+ resize: function () {
+ this.map.updateSize();
+ }
}
- }
-});
+ });
+
+})();