Add 'projection' and 'coordinateFormat' to ol.control.MousePosition

This commit is contained in:
Frederic Junod
2013-06-20 11:56:49 +02:00
parent 9d63217778
commit 22adf354e2
4 changed files with 99 additions and 29 deletions

View File

@@ -4,7 +4,9 @@ goog.require('ol.View2D');
goog.require('ol.control.MousePosition');
goog.require('ol.control.defaults');
goog.require('ol.coordinate');
goog.require('ol.dom.Input');
goog.require('ol.layer.TileLayer');
goog.require('ol.proj');
goog.require('ol.source.OSM');
var control = new ol.control.MousePosition({
@@ -32,6 +34,13 @@ var map = new ol.Map({
})
});
document.getElementById('projection').addEventListener('change', function() {
control.setProjection(this.value);
}, false);
var projection = new ol.dom.Input(document.getElementById('projection'));
projection.on('change:value', function() {
control.setProjection(ol.proj.get(projection.getValue()));
});
var precision = new ol.dom.Input(document.getElementById('precision'));
precision.on('change:value', function() {
var format = ol.coordinate.createStringXY(precision.getValue());
control.setCoordinateFormat(format);
});