O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for Action – determining LonLat coordinates

Let's take a look at a couple of examples on coordinates from our previous maps.

  1. Open up the final example from Chapter 1.
  2. Pan around the map in any direction. Then, in Firebug, type:
    map.getCenter();
  3. Depending on where you have panned, your output should read something like this:
    lon=-72.8125, lat=19.6875
    
  4. Now, open up the example from the beginning of this chapter.
  5. Pan around, and then in Firebug type:
    map.getCenter();
  6. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required