aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/map
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-03-29 20:07:37 +1300
committerGitHub <noreply@github.com>2017-03-29 20:07:37 +1300
commitde980d0d3b4b87bc21fa037bafd90f6f72f46082 (patch)
tree4d08bda2df63e2131fc76600f882186d4153fb8f /web/app/view/map
parent99a0ed4ec3c79f7065b94000c7f225d4a671e8b0 (diff)
parent9bed98677f78feabb89b58f72584bf1a7db87e60 (diff)
downloadtrackermap-web-de980d0d3b4b87bc21fa037bafd90f6f72f46082.tar.gz
trackermap-web-de980d0d3b4b87bc21fa037bafd90f6f72f46082.tar.bz2
trackermap-web-de980d0d3b4b87bc21fa037bafd90f6f72f46082.zip
Merge pull request #457 from Abyss777/geofence_map
Zoom to edited geofence or main Map
Diffstat (limited to 'web/app/view/map')
-rw-r--r--web/app/view/map/GeofenceMap.js10
-rw-r--r--web/app/view/map/GeofenceMapController.js15
2 files changed, 19 insertions, 6 deletions
diff --git a/web/app/view/map/GeofenceMap.js b/web/app/view/map/GeofenceMap.js
index 37d3be74..6b06ae98 100644
--- a/web/app/view/map/GeofenceMap.js
+++ b/web/app/view/map/GeofenceMap.js
@@ -65,14 +65,12 @@ Ext.define('Traccar.view.map.GeofenceMap', {
map = this.map;
this.features = new ol.Collection();
- if (this.area !== '') {
+ if (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]);
- }
+ this.mapView.fit(geometry);
+ } else {
+ this.controller.fireEvent('mapstaterequest');
}
fillColor = ol.color.asArray(Traccar.Style.mapGeofenceColor);
fillColor[3] = Traccar.Style.mapGeofenceOverlayOpacity;
diff --git a/web/app/view/map/GeofenceMapController.js b/web/app/view/map/GeofenceMapController.js
index ffafb7f8..f075ac93 100644
--- a/web/app/view/map/GeofenceMapController.js
+++ b/web/app/view/map/GeofenceMapController.js
@@ -23,6 +23,16 @@ Ext.define('Traccar.view.map.GeofenceMapController', {
'Traccar.GeofenceConverter'
],
+ config: {
+ listen: {
+ controller: {
+ '*': {
+ mapstate: 'setMapState'
+ }
+ }
+ }
+ },
+
onSaveClick: function (button) {
var geometry, projection;
if (this.getView().getFeatures().getLength() > 0) {
@@ -40,5 +50,10 @@ Ext.define('Traccar.view.map.GeofenceMapController', {
onTypeSelect: function (combo) {
this.getView().removeInteraction();
this.getView().addInteraction(combo.getValue());
+ },
+
+ setMapState: function (lat, lon, zoom) {
+ this.getView().getMapView().setCenter(ol.proj.fromLonLat([lon, lat]));
+ this.getView().getMapView().setZoom(zoom);
}
});