Skip to content

Commit

Permalink
Merge pull request #2465 from camptocamp/fix_geolocation_fit_accuracy
Browse files Browse the repository at this point in the history
Fix geolocation accuracy recenter
  • Loading branch information
fredj authored Mar 22, 2017
2 parents c8b9810 + 6c66017 commit bd5f9f1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/directives/mobilegeolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,15 @@ ngeo.MobileGeolocationController = function($scope, $element,
function() {
this.accuracyFeature_.setGeometry(
this.geolocation_.getAccuracyGeometry());
this.setPosition_();
},
this);

ol.events.listen(
this.geolocation_,
ol.Object.getChangeEventType(ol.Geolocation.Property.POSITION),
function(e) {
this.setPosition_(e);
function() {
this.setPosition_();
},
this);

Expand Down Expand Up @@ -258,24 +259,23 @@ 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);

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(/** @type {!ol.geom.Polygon} */ (accuracy), size);
}
this.viewChangedByMe_ = false;
}
Expand Down

0 comments on commit bd5f9f1

Please sign in to comment.