O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

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 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, Getting Started with OpenLayers. Pan around the map in any direction. Then, in Chrome Developer Tools, type the following:
    map.getView().getCenter();

    Depending on where you have panned, your output should read something like the following:

    [9397474.0038099,3595597.9798909]
    
  2. Now, open up the example from the beginning of this chapter. Pan around, and then in Chrome Developer Tools, type:
    map.getView().getCenter();

    You should see something like the following:

    [-72.8125, 19.6875]
    
  3. Reuse this last array to change the representation of your degrees values. For calculation, we always use dd (

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