-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

OpenLayers 2.10 Beginner's Guide

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 the maxExtent
, maxResolution
, and units
properties. If we use a projection other than the default projection, we need to tell OpenLayers the type of coordinates to use, and setting the maxExtent
is one way to do this. The projection we're going to use is EPSG: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:
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...
Change the font size
Change margin width
Change background colour