From eda73a4305647e60ea3b06cd76cfa0a78dc0d3fd Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 15 Jun 2021 20:53:08 -0700 Subject: Fit geofence on edit (fix #862) --- web/app/view/map/GeofenceMap.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/app/view/map/GeofenceMap.js b/web/app/view/map/GeofenceMap.js index 18c33862..347b1a9f 100644 --- a/web/app/view/map/GeofenceMap.js +++ b/web/app/view/map/GeofenceMap.js @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2016 - 2021 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 @@ -79,16 +79,21 @@ Ext.define('Traccar.view.map.GeofenceMap', { }, initMap: function () { - var map, featureOverlay, geometry, fillColor; + var map, mapView, featureOverlay, geometry, fillColor; this.callParent(); map = this.map; + mapView = this.mapView; this.features = new ol.Collection(); if (this.area) { - geometry = Traccar.GeofenceConverter.wktToGeometry(this.mapView, this.area); + geometry = Traccar.GeofenceConverter.wktToGeometry(mapView, this.area); this.features.push(new ol.Feature(geometry)); - this.mapView.fit(geometry); + this.map.once('postrender', function (event) { + mapView.fit(geometry, { + padding: [20, 20, 20, 20] + }); + }); } else { this.controller.fireEvent('mapstaterequest'); } -- cgit v1.2.3