diff options
author | Abyss777 <abyss@fox5.ru> | 2016-11-28 17:14:59 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-11-28 17:14:59 +0500 |
commit | e130b94f3d7402e7bbaa515ab084f96db283c1d8 (patch) | |
tree | 614df5862c7d3243f0aecaf1d1fd19cf04445aa2 /web/app/view/MapMarkerController.js | |
parent | 104debca9ccf9d8808805519670103377384ae7b (diff) | |
download | trackermap-web-e130b94f3d7402e7bbaa515ab084f96db283c1d8.tar.gz trackermap-web-e130b94f3d7402e7bbaa515ab084f96db283c1d8.tar.bz2 trackermap-web-e130b94f3d7402e7bbaa515ab084f96db283c1d8.zip |
Split functions to controllers
Diffstat (limited to 'web/app/view/MapMarkerController.js')
-rw-r--r-- | web/app/view/MapMarkerController.js | 82 |
1 files changed, 4 insertions, 78 deletions
diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index bea1253b..4ef55bbe 100644 --- a/web/app/view/MapMarkerController.js +++ b/web/app/view/MapMarkerController.js @@ -1,5 +1,6 @@ /* * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org) + * Copyright 2016 Andrey Kunitsyn (andrey@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 @@ -15,14 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -Ext.define('Traccar.view.MapController', { +Ext.define('Traccar.view.MapMarkerController', { extend: 'Ext.app.ViewController', - alias: 'controller.map', + alias: 'controller.mapMarker', requires: [ 'Traccar.model.Position', 'Traccar.model.Device', - 'Traccar.GeofenceConverter', 'Traccar.DeviceImages' ], @@ -31,8 +31,7 @@ Ext.define('Traccar.view.MapController', { controller: { '*': { selectdevice: 'selectDevice', - selectreport: 'selectReport', - mapstaterequest: 'getMapState' + selectreport: 'selectReport' } }, store: { @@ -48,12 +47,6 @@ Ext.define('Traccar.view.MapController', { '#ReportRoute': { load: 'loadReport', clear: 'clearReport' - }, - '#Geofences': { - load: 'showGeofences', - add: 'updateGeofences', - update: 'updateGeofences', - remove: 'updateGeofences' } }, component: { @@ -69,11 +62,6 @@ Ext.define('Traccar.view.MapController', { this.reportMarkers = {}; this.liveRoutes = {}; this.liveRouteLength = Traccar.app.getAttributePreference('web.liveRouteLength', 10); - this.lookupReference('showReportsButton').setVisible(Traccar.app.isMobile()); - }, - - showReports: function () { - Traccar.app.showReports(true); }, getDeviceColor: function (device) { @@ -126,16 +114,6 @@ Ext.define('Traccar.view.MapController', { } }, - onFollowClick: function (button, pressed) { - if (pressed && this.selectedMarker) { - this.getView().getMapView().setCenter(this.selectedMarker.getGeometry().getCoordinates()); - } - }, - - showLiveRoutes: function (button) { - this.getView().getLiveRouteLayer().setVisible(button.pressed); - }, - updateLatest: function (store, data) { var i, position, device; @@ -387,57 +365,5 @@ Ext.define('Traccar.view.MapController', { this.fireEvent('selectreport', record, false); } } - }, - - getMapState: function () { - var zoom, center, projection; - projection = this.getView().getMapView().getProjection(); - center = ol.proj.transform(this.getView().getMapView().getCenter(), projection, 'EPSG:4326'); - zoom = this.getView().getMapView().getZoom(); - this.fireEvent('mapstate', center[1], center[0], zoom); - }, - - getGeofenceStyle: function (label) { - return new ol.style.Style({ - fill: new ol.style.Fill({ - color: Traccar.Style.mapGeofenceOverlay - }), - stroke: new ol.style.Stroke({ - color: Traccar.Style.mapGeofenceColor, - width: Traccar.Style.mapGeofenceWidth - }), - text: new ol.style.Text({ - text: label, - fill: new ol.style.Fill({ - color: Traccar.Style.mapGeofenceTextColor - }), - stroke: new ol.style.Stroke({ - color: Traccar.Style.mapTextStrokeColor, - width: Traccar.Style.mapTextStrokeWidth - }), - font : Traccar.Style.mapTextFont - }) - }); - }, - - showGeofences: function () { - if (this.lookupReference('showGeofencesButton').pressed) { - Ext.getStore('Geofences').each(function (geofence) { - var feature = new ol.Feature(Traccar.GeofenceConverter - .wktToGeometry(this.getView().getMapView(), geofence.get('area'))); - feature.setStyle(this.getGeofenceStyle(geofence.get('name'))); - this.getView().getGeofencesSource().addFeature(feature); - return true; - }, this); - } else { - this.getView().getGeofencesSource().clear(); - } - }, - - updateGeofences: function () { - if (this.lookupReference('showGeofencesButton').pressed) { - this.getView().getGeofencesSource().clear(); - this.showGeofences(); - } } }); |