From 6e36522ed8aa7b4d1f6b4a7ac3fabb08de2d0387 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 4 Jul 2016 16:11:31 +0500 Subject: Load area for editing geofence. --- web/app/view/GeofenceMap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'web/app/view/GeofenceMap.js') diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js index e8a4dc5de..70584f41d 100644 --- a/web/app/view/GeofenceMap.js +++ b/web/app/view/GeofenceMap.js @@ -19,7 +19,8 @@ Ext.define('Traccar.view.GeofenceMap', { xtype: 'geofenceMapView', requires: [ - 'Traccar.view.GeofenceMapController' + 'Traccar.view.GeofenceMapController', + 'Traccar.GeofenceConverter' ], controller: 'geofenceMap', @@ -56,6 +57,9 @@ Ext.define('Traccar.view.GeofenceMap', { map = this.map; this.features = new ol.Collection(); + if (this.area !== "") { + this.features.push(new ol.Feature(Traccar.GeofenceConverter.wktToGeometry(this.mapView, this.area))); + } featureOverlay = new ol.layer.Vector({ source: new ol.source.Vector({ features: this.features -- cgit v1.2.3 From dc8db55c8a74d26644d9dc449b4f35c76a2e031f Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 4 Jul 2016 16:55:40 +0500 Subject: Center view to editing geofence --- web/app/view/GeofenceMap.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'web/app/view/GeofenceMap.js') diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js index 70584f41d..165daf40d 100644 --- a/web/app/view/GeofenceMap.js +++ b/web/app/view/GeofenceMap.js @@ -51,14 +51,20 @@ Ext.define('Traccar.view.GeofenceMap', { }, initMap: function () { - var map, featureOverlay; + var map, featureOverlay, geometry; this.callParent(); map = this.map; this.features = new ol.Collection(); if (this.area !== "") { - this.features.push(new ol.Feature(Traccar.GeofenceConverter.wktToGeometry(this.mapView, this.area))); + geometry = Traccar.GeofenceConverter.wktToGeometry(this.mapView, this.area); + this.features.push(new ol.Feature(geometry)); + if (geometry instanceof ol.geom.Circle) { + this.mapView.setCenter(geometry.getCenter()); + } else if (geometry instanceof ol.geom.Polygon) { + this.mapView.setCenter(geometry.getCoordinates()[0][0]); + } } featureOverlay = new ol.layer.Vector({ source: new ol.source.Vector({ -- cgit v1.2.3