Getter and setter support for bindTo

This commit is contained in:
Frederic Junod
2013-10-30 15:18:07 +01:00
parent 0814b2c5c6
commit 03cc533cb3
2 changed files with 84 additions and 8 deletions

View File

@@ -35,9 +35,16 @@ var map = new ol.Map({
});
var projectionSelect = new ol.dom.Input(document.getElementById('projection'));
projectionSelect.on('change:value', function() {
mousePositionControl.setProjection(ol.proj.get(projectionSelect.getValue()));
});
projectionSelect.bindTo('value', mousePositionControl, 'projection')
.transform(
function(code) {
// projectionSelect.value -> mousePositionControl.projection
return ol.proj.get(/** @type {string} */ (code));
},
function(projection) {
// mousePositionControl.projection -> projectionSelect.value
return projection.getCode();
});
var precisionInput = document.getElementById('precision');
precisionInput.addEventListener('change', function() {