Time for Action – determining LonLat coordinates
Let's take a look at a couple of examples on coordinates from our previous maps.
Open up the final example from Chapter 1.
Pan around the map in any direction. Then, in Firebug, type:
map.getCenter();
Depending on where you have panned, your output should read something like this:
lon=-72.8125, lat=19.6875
Now, open up the example from the beginning of this chapter.
Pan around, and then in Firebug type:
map.getCenter();
You should see something like:
lon=-9397474.0038099,lat=3595597.9798909
What Just Happened?
We just took a look at the longitude and latitude values for the center of the map in two different maps with different projections. When we call map.getCenter()
, we get back an OpenLayers LonLat object.
In the first map, the max extent of the map was between -180° and 180° for longitude, and between -90° and 90° for latitude. These are the values used by the EPSG: 4326
, and it is a longitude/latitude type of coordinate system. The values for...