Add ol.control.MousePosition.setProjection

This commit is contained in:
Frederic Junod
2013-05-06 11:46:48 +02:00
parent 153fea538a
commit 916dde0045
4 changed files with 36 additions and 23 deletions

View File

@@ -7,19 +7,18 @@ goog.require('ol.coordinate');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OSM');
var control = new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:4326',
// comment the following two lines to have the mouse position
// be placed within the map.
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
undefinedHTML: ' '
});
var map = new ol.Map({
controls: ol.control.defaults({}, [
new ol.control.MousePosition({
coordinateFormat: ol.coordinate.toStringHDMS,
projection: 'EPSG:4326',
// comment the following two lines to have the mouse position
// be placed within the map.
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
undefinedHTML: ' '
})
]),
controls: ol.control.defaults({}, [control]),
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
@@ -32,3 +31,7 @@ var map = new ol.Map({
zoom: 2
})
});
document.getElementById('projection').addEventListener('change', function() {
control.setProjection(this.value);
}, false);