Dispatch an error on Geolocation failure
This commit is contained in:
@@ -53,7 +53,8 @@
|
||||
<button id="locate"><i class="icon-screenshot"></i> locate</button>
|
||||
<div id="tags">geolocation, openstreetmap</div>
|
||||
</div>
|
||||
|
||||
<div class="span4 pull-right">
|
||||
<div id="info" class="alert alert-error" style="display: none;"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -36,6 +36,12 @@ geolocation.addEventListener('accuracy_changed', function() {
|
||||
title: this.getAccuracy() + 'm from this point'
|
||||
});
|
||||
});
|
||||
geolocation.on('error', function(error) {
|
||||
var info = document.getElementById('info');
|
||||
info.innerHTML = error.message;
|
||||
info.style.display = '';
|
||||
});
|
||||
|
||||
|
||||
$('#locate').click(function() {
|
||||
geolocation.setTracking(true);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// FIXME handle geolocation not supported
|
||||
// FIXME handle geolocation errors
|
||||
|
||||
goog.provide('ol.Geolocation');
|
||||
goog.provide('ol.GeolocationProperty');
|
||||
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.math');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Object');
|
||||
@@ -163,6 +163,8 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
|
||||
* @param {GeolocationPositionError} error error object.
|
||||
*/
|
||||
ol.Geolocation.prototype.positionError_ = function(error) {
|
||||
error.type = goog.events.EventType.ERROR;
|
||||
this.dispatchEvent(error);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user