From e130b94f3d7402e7bbaa515ab084f96db283c1d8 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 28 Nov 2016 17:14:59 +0500 Subject: Split functions to controllers --- web/app/view/MapMarkerController.js | 82 ++----------------------------------- 1 file changed, 4 insertions(+), 78 deletions(-) (limited to 'web/app/view/MapMarkerController.js') diff --git a/web/app/view/MapMarkerController.js b/web/app/view/MapMarkerController.js index bea1253..4ef55bb 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 . */ -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(); - } } }); -- cgit v1.2.3