Check if the Geolocation API is supported
This commit is contained in:
+15
-12
@@ -1,4 +1,5 @@
|
|||||||
// FIXME: handle errors ?
|
// FIXME handle geolocation not supported
|
||||||
|
// FIXME handle geolocation errors
|
||||||
|
|
||||||
goog.provide('ol.Geolocation');
|
goog.provide('ol.Geolocation');
|
||||||
goog.provide('ol.GeolocationProperty');
|
goog.provide('ol.GeolocationProperty');
|
||||||
@@ -36,18 +37,20 @@ ol.Geolocation = function(opt_positionOptions) {
|
|||||||
*/
|
*/
|
||||||
this.position_ = null;
|
this.position_ = null;
|
||||||
|
|
||||||
goog.events.listen(
|
if (ol.Geolocation.isSupported) {
|
||||||
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
|
goog.events.listen(
|
||||||
this.handleProjectionChanged_, false, this);
|
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
|
||||||
|
this.handleProjectionChanged_, false, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.watchId_ = navigator.geolocation.watchPosition(
|
this.watchId_ = navigator.geolocation.watchPosition(
|
||||||
goog.bind(this.positionChange_, this),
|
goog.bind(this.positionChange_, this),
|
||||||
goog.bind(this.positionError_, this),
|
goog.bind(this.positionError_, this),
|
||||||
opt_positionOptions);
|
opt_positionOptions);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
goog.inherits(ol.Geolocation, ol.Object);
|
goog.inherits(ol.Geolocation, ol.Object);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user