Remove jQuery use from geolocation example
This commit is contained in:
+10
-6
@@ -36,17 +36,21 @@ var geolocation = new ol.Geolocation({
|
|||||||
projection: view.getProjection()
|
projection: view.getProjection()
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#track').on('change', function() {
|
function el(id) {
|
||||||
|
return document.getElementById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
el('track').addEventListener('change', function() {
|
||||||
geolocation.setTracking(this.checked);
|
geolocation.setTracking(this.checked);
|
||||||
});
|
});
|
||||||
|
|
||||||
// update the HTML page when the position changes.
|
// update the HTML page when the position changes.
|
||||||
geolocation.on('change', function() {
|
geolocation.on('change', function() {
|
||||||
$('#accuracy').text(geolocation.getAccuracy() + ' [m]');
|
el('accuracy').innerText = geolocation.getAccuracy() + ' [m]';
|
||||||
$('#altitude').text(geolocation.getAltitude() + ' [m]');
|
el('altitude').innerText = geolocation.getAltitude() + ' [m]';
|
||||||
$('#altitudeAccuracy').text(geolocation.getAltitudeAccuracy() + ' [m]');
|
el('altitudeAccuracy').innerText = geolocation.getAltitudeAccuracy() + ' [m]';
|
||||||
$('#heading').text(geolocation.getHeading() + ' [rad]');
|
el('heading').innerText = geolocation.getHeading() + ' [rad]';
|
||||||
$('#speed').text(geolocation.getSpeed() + ' [m/s]');
|
el('speed').innerText = geolocation.getSpeed() + ' [m/s]';
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle geolocation error.
|
// handle geolocation error.
|
||||||
|
|||||||
Reference in New Issue
Block a user