In my mobile application I am using OpenLayers and trying to capture current position of the user by using GeoLocation.getPosition() method.
The method sometimes returns position and sometimes return undefined. The behaviour is strange ! The GeoLocation object has value in it. Below is my code:
Geolocation object creation :
this.GeoLocationObj = new GeoLocation({
projection: this.map.getView().getProjection(),
tracking: true,
trackingOptions: {
enableHighAccuracy: true
}
});
Use of this to get the position:
var position = this.GeoLocationObj.getPosition();
this.map.getView().setCenter(position);
this.map.getView().setZoom(18);
this.positionFeature.setGeometry(new Point(position) )
What should I change?
this.GeoLocationObj.on('error', ...)
as well asthis.GeoLocationObj.on('change:position', ...)
– Mike Oct 20 '19 at 11:36