Merge pull request #1198 from fredj/bindTo_transform
ol.Object#bindTo: getter and setter
This commit is contained in:
@@ -36,23 +36,30 @@ var visible = new ol.dom.Input(document.getElementById('visible'));
|
||||
visible.bindTo('checked', layer, 'visible');
|
||||
|
||||
var opacity = new ol.dom.Input(document.getElementById('opacity'));
|
||||
opacity.bindTo('valueAsNumber', layer, 'opacity');
|
||||
opacity.bindTo('value', layer, 'opacity')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
var hue = new ol.dom.Input(document.getElementById('hue'));
|
||||
hue.bindTo('valueAsNumber', layer, 'hue');
|
||||
hue.bindTo('value', layer, 'hue')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
var saturation = new ol.dom.Input(document.getElementById('saturation'));
|
||||
saturation.bindTo('valueAsNumber', layer, 'saturation');
|
||||
saturation.bindTo('value', layer, 'saturation')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
var contrast = new ol.dom.Input(document.getElementById('contrast'));
|
||||
contrast.bindTo('valueAsNumber', layer, 'contrast');
|
||||
contrast.bindTo('value', layer, 'contrast')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
var brightness = new ol.dom.Input(document.getElementById('brightness'));
|
||||
brightness.bindTo('valueAsNumber', layer, 'brightness');
|
||||
brightness.bindTo('value', layer, 'brightness')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
|
||||
var rotation = new ol.dom.Input(document.getElementById('rotation'));
|
||||
rotation.bindTo('valueAsNumber', map.getView(), 'rotation');
|
||||
rotation.bindTo('value', map.getView(), 'rotation')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
var resolution = new ol.dom.Input(document.getElementById('resolution'));
|
||||
resolution.bindTo('valueAsNumber', map.getView(), 'resolution');
|
||||
resolution.bindTo('value', map.getView(), 'resolution')
|
||||
.transform(parseFloat, String);
|
||||
|
||||
@@ -45,7 +45,8 @@ function bindInputs(layerid, layer) {
|
||||
$.each(['opacity', 'hue', 'saturation', 'contrast', 'brightness'],
|
||||
function(i, v) {
|
||||
new ol.dom.Input($(layerid + ' .' + v)[0])
|
||||
.bindTo('valueAsNumber', layer, v);
|
||||
.bindTo('value', layer, v)
|
||||
.transform(parseFloat, String);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user