From 91cd8f20cc4fd87dc8c2fb377b8f151532db6f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Fri, 14 Mar 2014 09:32:37 +0100 Subject: [PATCH] Use change event in geolocation example --- examples/geolocation.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/geolocation.js b/examples/geolocation.js index b693c7efc5..963b536f83 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -31,7 +31,8 @@ geolocation.bindTo('projection', view); var track = new ol.dom.Input(document.getElementById('track')); 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]'); $('#altitude').text(geolocation.getAltitude() + ' [m]'); $('#altitudeAccuracy').text(geolocation.getAltitudeAccuracy() + ' [m]'); @@ -39,13 +40,13 @@ geolocation.on('propertychange', function() { $('#speed').text(geolocation.getSpeed() + ' [m/s]'); }); +// handle geolocation error. geolocation.on('error', function(error) { var info = document.getElementById('info'); info.innerHTML = error.message; info.style.display = ''; }); - var accuracyFeature = new ol.Feature(); accuracyFeature.bindTo('geometry', geolocation, 'accuracyGeometry');