Hi,
your result is absolute right. For sphericalMercator (180,90) are ~(0,0).
You can calculate your lonlat from sphericalMercator bounds
new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)
or transform your coordinates to sphericalMercator
var lonlat = new OpenLayers.LonLat(lon, lat).transform(new
OpenLayers.Projection("EPSG:4326"),new
OpenLayers.Projection("EPSG:900913"));
Arnd
_____
Von: [email protected] [mailto:[email protected]] Im
Auftrag von Vincent Gulinao
Gesendet: Sonntag, 7. Februar 2010 05:38
An: [email protected]
Betreff: Re: [OpenLayers-Users] How to make OpenLayers.Map.panTo() work?
Sorry, accidentally sent...
I copied this from an example somewhere to start:
map = new OpenLayers.Map('map',
{
numZoomLevels: 19,
maxResolution: 156543.0399,
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
map.addLayers([layerMapnik]);
Then I call this function from html drop-down list's onchange:
function setCenter(region) {
lon = Math.random() * 360 - 180;
lat = Math.random() * 180 - 90;
var lonlat = new OpenLayers.LonLat(lon, lat);
map.panTo(lonlat);
}
... but it only brings me to (I believe) 0,0.
I've been trying to figure it out for hours but with no luck. Please help.
TIA.
On Sun, Feb 7, 2010 at 12:30 PM, Vincent Gulinao <[email protected]>
wrote:
I'm a newbie, I copied this from an example somewhere to start:
map = new OpenLayers.Map('map',
{
numZoomLevels: 19,
maxResolution: 156543.0399,
units: 'm',
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326")
});
var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
map.addLayers([layerMapnik,layerTah]);
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users