diff options
Diffstat (limited to 'web/app/view/map/Map.js')
-rw-r--r-- | web/app/view/map/Map.js | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/web/app/view/map/Map.js b/web/app/view/map/Map.js new file mode 100644 index 00000000..d4e654eb --- /dev/null +++ b/web/app/view/map/Map.js @@ -0,0 +1,140 @@ +/* + * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +Ext.define('Traccar.view.map.Map', { + extend: 'Traccar.view.map.BaseMap', + xtype: 'mapView', + + requires: [ + 'Traccar.view.map.MapController', + 'Traccar.view.SettingsMenu' + ], + + controller: 'map', + + title: Strings.mapTitle, + tbar: { + componentCls: 'toolbar-header-style', + defaults: { + xtype: 'button', + tooltipType: 'title', + stateEvents: ['toggle'], + enableToggle: true, + stateful: { + pressed: true + } + }, + items: [{ + xtype: 'tbtext', + html: Strings.mapTitle, + baseCls: 'x-panel-header-title-default' + }, { + xtype: 'tbfill' + }, { + handler: 'showReports', + reference: 'showReportsButton', + glyph: 'xf0f6@FontAwesome', + stateful: false, + enableToggle: false, + tooltip: Strings.reportTitle + }, { + handler: 'updateGeofences', + reference: 'showGeofencesButton', + glyph: 'xf21d@FontAwesome', + pressed: true, + stateId: 'show-geofences-button', + tooltip: Strings.sharedGeofences + }, { + handler: 'showLiveRoutes', + reference: 'showLiveRoutes', + glyph: 'xf1b0@FontAwesome', + stateId: 'show-live-routes-button', + tooltip: Strings.mapLiveRoutes + }, { + reference: 'deviceFollowButton', + glyph: 'xf05b@FontAwesome', + tooltip: Strings.deviceFollow, + stateId: 'device-follow-button', + toggleHandler: 'onFollowClick' + }, { + id: 'soundButton', + glyph: 'xf0a2@FontAwesome', + tooltip: Strings.sharedSound, + stateId: 'sound-button' + }, { + xtype: 'settingsMenu', + enableToggle: false + }] + }, + + getMarkersSource: function () { + return this.markersSource; + }, + + getAccuracySource: function () { + return this.accuracySource; + }, + + getRouteSource: function () { + return this.routeSource; + }, + + getGeofencesSource: function () { + return this.geofencesSource; + }, + + getLiveRouteSource: function () { + return this.liveRouteSource; + }, + + getLiveRouteLayer: function () { + return this.liveRouteLayer; + }, + + initMap: function () { + this.callParent(); + + this.geofencesSource = new ol.source.Vector({}); + this.map.addLayer(new ol.layer.Vector({ + name: 'geofencesLayer', + source: this.geofencesSource + })); + + this.liveRouteSource = new ol.source.Vector({}); + this.liveRouteLayer = new ol.layer.Vector({ + source: this.liveRouteSource, + visible: false + }); + this.map.addLayer(this.liveRouteLayer); + + this.routeSource = new ol.source.Vector({}); + this.map.addLayer(new ol.layer.Vector({ + source: this.routeSource + })); + + this.accuracySource = new ol.source.Vector({}); + this.map.addLayer(new ol.layer.Vector({ + name: 'accuracyLayer', + source: this.accuracySource + })); + + this.markersSource = new ol.source.Vector({}); + this.map.addLayer(new ol.layer.Vector({ + source: this.markersSource + })); + } +}); |