Check if the Geolocation API is supported

This commit is contained in:
Frederic Junod
2013-02-07 16:20:15 +01:00
parent 44a5eca437
commit a36145fc1f
+4 -1
View File
@@ -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,6 +37,7 @@ ol.Geolocation = function(opt_positionOptions) {
*/ */
this.position_ = null; this.position_ = null;
if (ol.Geolocation.isSupported) {
goog.events.listen( goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION), this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this); this.handleProjectionChanged_, false, this);
@@ -48,6 +50,7 @@ ol.Geolocation = function(opt_positionOptions) {
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);