Don't bind to ol.View projection property

This commit is contained in:
Frederic Junod
2014-08-07 12:59:15 +02:00
parent 0a963d4615
commit 0d6cc22bf0
4 changed files with 9 additions and 7 deletions

View File

@@ -47,13 +47,13 @@ var positions = new ol.geom.LineString([],
// Geolocation Control // Geolocation Control
var geolocation = new ol.Geolocation(/** @type {olx.GeolocationOptions} */ ({ var geolocation = new ol.Geolocation(/** @type {olx.GeolocationOptions} */ ({
projection: view.getProjection(),
trackingOptions: { trackingOptions: {
maximumAge: 10000, maximumAge: 10000,
enableHighAccuracy: true, enableHighAccuracy: true,
timeout: 600000 timeout: 600000
} }
})); }));
geolocation.bindTo('projection', view);
var deltaMean = 500; // the geolocation sampling period mean in ms var deltaMean = 500; // the geolocation sampling period mean in ms

View File

@@ -30,8 +30,9 @@ var map = new ol.Map({
view: view view: view
}); });
var geolocation = new ol.Geolocation(); var geolocation = new ol.Geolocation({
geolocation.bindTo('projection', view); projection: view.getProjection()
});
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');

View File

@@ -25,9 +25,9 @@ var map = new ol.Map({
}); });
var geolocation = new ol.Geolocation({ var geolocation = new ol.Geolocation({
projection: view.getProjection(),
tracking: true tracking: true
}); });
geolocation.bindTo('projection', view);
geolocation.once('change:position', function() { geolocation.once('change:position', function() {
view.setCenter(geolocation.getPosition()); view.setCenter(geolocation.getPosition());
view.setResolution(2.388657133911758); view.setResolution(2.388657133911758);

View File

@@ -42,9 +42,10 @@ ol.GeolocationProperty = {
* *
* Example: * Example:
* *
* var geolocation = new ol.Geolocation(); * var geolocation = new ol.Geolocation({
* // take the projection to use from the map's view * // take the projection to use from the map's view
* geolocation.bindTo('projection', map.getView()); * projection: view.getprojection()
* });
* // listen to changes in position * // listen to changes in position
* geolocation.on('change', function(evt) { * geolocation.on('change', function(evt) {
* window.console.log(geolocation.getPosition()); * window.console.log(geolocation.getPosition());