AW: [OpenLayers-Users] how to return getcenter and getextent?
Arnd Wippermann
arnd.wippermann at web.de
Mon Apr 4 16:06:32 EDT 2011
what means "it doesn´t work as I expected"?
as your map is in EPSG:900913, you will not get any reasonable result by
transforming these coordinates from EPSG:4326 to EPSG:900913.
Arnd
_____
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Robert
Buckley
Gesendet: Montag, 4. April 2011 18:52
An: users at openlayers.org
Betreff: [OpenLayers-Users] how to return getcenter and getextent?
Hi,
I want to call the extent and center of my openlayers map and put the
results in a msgbox. Unfortunately i´m missing something because it doesn´t
work as I expected.
Could someone explain how to simply get the extents and center of the
current view? The map is in 900913
var map;
var extent = new OpenLayers.Bounds(10.0, 51.8, 10.8, 52.8).transform(
new OpenLayers.Projection(epsg4326), // transform from WGS
1984
new OpenLayers.Projection(epsg900913) // to Spherical
Mercator Projection
);
var mapOptions = {
projection: epsg900913,
displayProjection: new OpenLayers.Projection(epsg4326),
units: "m",
minScale: 1000,
maxResolution: 156543,
maxExtent: new OpenLayers.Bounds(1092438.008103,
6799532.287192, 1245312.064646, 6921831.532427),
controls: [
new OpenLayers.Control.MouseDefaults(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.ScaleLine({
maxWidth: 200,
geodesic: true
})]
};
map = new OpenLayers.Map("map_wea",mapOptions);
// my base map
var mapnik = new OpenLayers.Layer.OSM();
// messagebox to display info about map
var latlon = map.getCenter();
var currentlatlon = new OpenLayers.LonLat(latlon).transform(
new OpenLayers.Projection(epsg4326), // transform from WGS
1984
new OpenLayers.Projection(epsg900913) // to Spherical
Mercator Projection
);
var mapextent = map.getExtent();
var currentmapextent= new
OpenLayers.Bounds(mapextent).transform(
new OpenLayers.Projection(epsg4326), // transform from WGS
1984
new OpenLayers.Projection(epsg900913) // to Spherical
Mercator Projection
);
Ext.Msg.alert('bounds', currentmapextent + " / " +
currentlatlon);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110404/328a4ce6/attachment.html
More information about the Users
mailing list