Deal with ol.global issues

This commit is contained in:
Tim Schaub
2016-08-31 07:42:35 -06:00
parent 9e1a3f59e3
commit ff8a84a220
10 changed files with 64 additions and 45 deletions

View File

@@ -3,9 +3,9 @@
goog.provide('ol.Geolocation');
goog.require('ol');
goog.require('ol.Object');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.Object');
goog.require('ol.geom.Polygon');
goog.require('ol.has');
goog.require('ol.math');
@@ -113,15 +113,17 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
* @private
*/
ol.Geolocation.prototype.handleTrackingChanged_ = function() {
var global = ol.global;
if (ol.has.GEOLOCATION) {
var navigator = global.navigator;
var tracking = this.getTracking();
if (tracking && this.watchId_ === undefined) {
this.watchId_ = ol.global.navigator.geolocation.watchPosition(
this.watchId_ = navigator.geolocation.watchPosition(
this.positionChange_.bind(this),
this.positionError_.bind(this),
this.getTrackingOptions());
} else if (!tracking && this.watchId_ !== undefined) {
ol.global.navigator.geolocation.clearWatch(this.watchId_);
navigator.geolocation.clearWatch(this.watchId_);
this.watchId_ = undefined;
}
}