Time for Action – using different projection codes
Let's create a basic map using a different projection.
Using the template code, recreate your map object the following way. We'll be specifying the
projection
property, along with themaxExtent
,maxResolution
, andunits
properties. If we use a projection other than the default projection, we need to tell OpenLayers the type of coordinates to use, and setting themaxExtent
is one way to do this. The projection we're going to use isEPSG:900913
, a projection used by Google Maps and other third party APIs.map = new OpenLayers.Map('map_element', { projection: 'EPSG:900913', maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34), maxResolution: 156543.0339, units: 'm' });
Save the file, we'll refer to it as
chapter4_ex1.html
.You should see something like the following:
What Just Happened?
We just created a map with the projection EPSG:900913
. You'll notice that it looks quite a bit different than the maps we've...