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 – creating a Google Maps layer

Let's take a look at how to create a Google Maps layer.

  1. From this point onward, I'm going to assume that when I say "create a new map" you will use the template from http://vasir.net/openlayers_book/, or create a copy of the example from Chapter 1 and remove the WMS layer calls (they both result in the same code). So, create a new map.
  2. The first thing we'll need to do is add in a script tag to the <head> section that references the Google API library. This allows us to actually use the Google Maps library:
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
  3. Now, we'll need to create a Google Maps layer object. We won't pass in any additional settings, so the default settings will be ...

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