Files
openlayers/examples/mouse-position.js
2013-05-07 17:33:33 +02:00

35 lines
910 B
JavaScript

goog.require('ol.Map');
goog.require('ol.RendererHints');
goog.require('ol.View2D');
goog.require('ol.control.MousePosition');
goog.require('ol.control.defaults');
goog.require('ol.coordinate');
goog.require('ol.layer.TileLayer');
goog.require('ol.source.OSM');
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: ' '
})
]),
layers: [
new ol.layer.TileLayer({
source: new ol.source.OSM()
})
],
renderers: ol.RendererHints.createFromQueryData(),
target: 'map',
view: new ol.View2D({
center: [0, 0],
zoom: 2
})
});