From dcfa60f0e43e41d7432b03207fa287434709e833 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 22 Mar 2017 12:09:13 +0100 Subject: [PATCH 1/2] Fix geolocation accuracy recenter --- src/directives/mobilegeolocation.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/directives/mobilegeolocation.js b/src/directives/mobilegeolocation.js index 211681a1872..af33ff7df1d 100644 --- a/src/directives/mobilegeolocation.js +++ b/src/directives/mobilegeolocation.js @@ -168,9 +168,10 @@ ngeo.MobileGeolocationController = function($scope, $element, ol.events.listen( this.geolocation_, ol.Object.getChangeEventType(ol.Geolocation.Property.ACCURACY_GEOMETRY), - function() { + function(e) { this.accuracyFeature_.setGeometry( this.geolocation_.getAccuracyGeometry()); + this.setPosition_(e); }, this); @@ -266,16 +267,16 @@ ngeo.MobileGeolocationController.prototype.setPosition_ = function(event) { var point = new ol.geom.Point(position); this.positionFeature_.setGeometry(point); + var accuracy = this.accuracyFeature_.getGeometry(); if (this.follow_) { this.viewChangedByMe_ = true; if (this.zoom_ !== undefined) { this.map_.getView().setCenter(position); this.map_.getView().setZoom(this.zoom_); - } else { - var polygon = /** @type {!ol.geom.Polygon} */ (this.geolocation_.getAccuracyGeometry()); + } else if (accuracy) { var size = /** @type {!ol.Size} */ (this.map_.getSize()); - this.map_.getView().fit(polygon, size); + this.map_.getView().fit(accuracy, size); } this.viewChangedByMe_ = false; } From 6c660177518fab8850f55b6d866e930b8c39f7b7 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 22 Mar 2017 12:11:59 +0100 Subject: [PATCH 2/2] Remove unused 'event' param --- src/directives/mobilegeolocation.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/directives/mobilegeolocation.js b/src/directives/mobilegeolocation.js index af33ff7df1d..2a17978132f 100644 --- a/src/directives/mobilegeolocation.js +++ b/src/directives/mobilegeolocation.js @@ -168,18 +168,18 @@ ngeo.MobileGeolocationController = function($scope, $element, ol.events.listen( this.geolocation_, ol.Object.getChangeEventType(ol.Geolocation.Property.ACCURACY_GEOMETRY), - function(e) { + function() { this.accuracyFeature_.setGeometry( this.geolocation_.getAccuracyGeometry()); - this.setPosition_(e); + this.setPosition_(); }, this); ol.events.listen( this.geolocation_, ol.Object.getChangeEventType(ol.Geolocation.Property.POSITION), - function(e) { - this.setPosition_(e); + function() { + this.setPosition_(); }, this); @@ -259,10 +259,9 @@ ngeo.MobileGeolocationController.prototype.untrack_ = function() { /** - * @param {ol.ObjectEvent} event Event. * @private */ -ngeo.MobileGeolocationController.prototype.setPosition_ = function(event) { +ngeo.MobileGeolocationController.prototype.setPosition_ = function() { var position = /** @type {ol.Coordinate} */ (this.geolocation_.getPosition()); var point = new ol.geom.Point(position); @@ -276,7 +275,7 @@ ngeo.MobileGeolocationController.prototype.setPosition_ = function(event) { this.map_.getView().setZoom(this.zoom_); } else if (accuracy) { var size = /** @type {!ol.Size} */ (this.map_.getSize()); - this.map_.getView().fit(accuracy, size); + this.map_.getView().fit(/** @type {!ol.geom.Polygon} */ (accuracy), size); } this.viewChangedByMe_ = false; }