Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I just started to learn Open Map and I am having some difficulty working with the API. This may look trivial, but please bear with me. I am trying to get Open Map to display a region of the map bounded by the bounds variable. Having specified the unit as degrees, I would expect that the bounds shown would also be in degrees. But it seems to me that it is in a different unit which is much smaller than degrees:

var options = {
 projection: 'EPSG:4326'
 ,units: 'degrees'
};
var map = new OpenLayers.Map('map',options);
var bounds = new OpenLayers.Bounds(-100, -90, 100, 90);
var osm = new OpenLayers.Layer.OSM();            
var gmap = new OpenLayers.Layer.Google("Google Streets");
map.addLayers([osm, gmap]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToExtent(bounds, true);

My question is, how do I get open map to parse the input bounds as degrees?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You should use transform method of OpenLayers.Bounds object:

epsg4326 = new OpenLayers.Projection('EPSG:4326');
epsg900913 = new OpenLayers.Projection('EPSG:900913');
bbox = new OpenLayers.Bounds(-100, -80, 100, 80);
bounds = bbox.transform(epsg4326,epsg900913);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.