Use change event in geolocation example
This commit is contained in:
@@ -31,7 +31,8 @@ geolocation.bindTo('projection', view);
|
|||||||
var track = new ol.dom.Input(document.getElementById('track'));
|
var track = new ol.dom.Input(document.getElementById('track'));
|
||||||
track.bindTo('checked', geolocation, 'tracking');
|
track.bindTo('checked', geolocation, 'tracking');
|
||||||
|
|
||||||
geolocation.on('propertychange', function() {
|
// update the HTML page when the position changes.
|
||||||
|
geolocation.on('change', function() {
|
||||||
$('#accuracy').text(geolocation.getAccuracy() + ' [m]');
|
$('#accuracy').text(geolocation.getAccuracy() + ' [m]');
|
||||||
$('#altitude').text(geolocation.getAltitude() + ' [m]');
|
$('#altitude').text(geolocation.getAltitude() + ' [m]');
|
||||||
$('#altitudeAccuracy').text(geolocation.getAltitudeAccuracy() + ' [m]');
|
$('#altitudeAccuracy').text(geolocation.getAltitudeAccuracy() + ' [m]');
|
||||||
@@ -39,13 +40,13 @@ geolocation.on('propertychange', function() {
|
|||||||
$('#speed').text(geolocation.getSpeed() + ' [m/s]');
|
$('#speed').text(geolocation.getSpeed() + ' [m/s]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// handle geolocation error.
|
||||||
geolocation.on('error', function(error) {
|
geolocation.on('error', function(error) {
|
||||||
var info = document.getElementById('info');
|
var info = document.getElementById('info');
|
||||||
info.innerHTML = error.message;
|
info.innerHTML = error.message;
|
||||||
info.style.display = '';
|
info.style.display = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var accuracyFeature = new ol.Feature();
|
var accuracyFeature = new ol.Feature();
|
||||||
accuracyFeature.bindTo('geometry', geolocation, 'accuracyGeometry');
|
accuracyFeature.bindTo('geometry', geolocation, 'accuracyGeometry');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user