From fe47299d6cc02a4e43a1d2f3a788897be8a6f5ce Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 2 Feb 2019 12:55:29 -0800 Subject: Fix openlayers upgrade issues (fix #724) --- web/app/GeofenceConverter.js | 7 +++---- web/app/view/map/BaseMap.js | 10 +++++----- web/app/view/map/GeofenceMap.js | 5 +++-- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'web/app') diff --git a/web/app/GeofenceConverter.js b/web/app/GeofenceConverter.js index 4891e7b..1f6ad37 100644 --- a/web/app/GeofenceConverter.js +++ b/web/app/GeofenceConverter.js @@ -45,7 +45,7 @@ Ext.define('Traccar.GeofenceConverter', { resolutionAtEquator = mapView.getResolution(); pointResolution = ol.proj.getPointResolution(projection, resolutionAtEquator, center); resolutionFactor = resolutionAtEquator / pointResolution; - radius = Number(coordinates[2]) / ol.proj.METERS_PER_UNIT.m * resolutionFactor; + radius = Number(coordinates[2]) / ol.proj.Units.METERS_PER_UNIT.m * resolutionFactor; geometry = new ol.geom.Circle(center, radius); } } @@ -74,9 +74,8 @@ Ext.define('Traccar.GeofenceConverter', { radius = geometry.getRadius(); edgeCoordinate = [center[0] + radius, center[1]]; center = ol.proj.transform(center, projection, 'EPSG:4326'); - earthSphere = new ol.Sphere(6378137); - groundRadius = earthSphere.haversineDistance(center, - ol.proj.transform(edgeCoordinate, projection, 'EPSG:4326')); + groundRadius = ol.sphere.getDistance( + center, ol.proj.transform(edgeCoordinate, projection, 'EPSG:4326'), 6378137) result = 'CIRCLE ('; result += center[1] + ' ' + center[0] + ', '; result += groundRadius.toFixed(1) + ')'; diff --git a/web/app/view/map/BaseMap.js b/web/app/view/map/BaseMap.js index f973fb8..4f0c8d4 100644 --- a/web/app/view/map/BaseMap.js +++ b/web/app/view/map/BaseMap.js @@ -30,7 +30,7 @@ Ext.define('Traccar.view.map.BaseMap', { }, initMap: function () { - var server, layer, type, bingKey, lat, lon, zoom, maxZoom, target, poiLayer; + var server, layer, type, bingKey, lat, lon, zoom, maxZoom, target, poiLayer, self = this; server = Traccar.app.getServer(); @@ -207,19 +207,19 @@ Ext.define('Traccar.view.map.BaseMap', { }); this.map.on('click', function (e) { - var i, features = this.map.getFeaturesAtPixel(e.pixel, { + var i, features = self.map.getFeaturesAtPixel(e.pixel, { layerFilter: function (layer) { return !layer.get('name'); } }); if (features) { for (i = 0; i < features.length; i++) { - this.fireEvent('selectfeature', features[i]); + self.fireEvent('selectfeature', features[i]); } } else { - this.fireEvent('deselectfeature'); + self.fireEvent('deselectfeature'); } - }, this); + }); }, listeners: { diff --git a/web/app/view/map/GeofenceMap.js b/web/app/view/map/GeofenceMap.js index 6b06ae9..8cef574 100644 --- a/web/app/view/map/GeofenceMap.js +++ b/web/app/view/map/GeofenceMap.js @@ -105,13 +105,14 @@ Ext.define('Traccar.view.map.GeofenceMap', { }, addInteraction: function (type) { + var self = this; this.draw = new ol.interaction.Draw({ features: this.features, type: type }); this.draw.on('drawstart', function () { - this.features.clear(); - }, this); + self.features.clear(); + }); this.map.addInteraction(this.draw); }, -- cgit v1.2.3