Remove jQuery use from geolocation example

This commit is contained in:
Tim Schaub
2015-04-15 09:05:47 -06:00
parent c3362c1685
commit 2f160d29c7
+10 -6
View File
@@ -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.