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 Vector Layer

In this first example, we'll use the code similar to what we just saw above—making use of all three classes to build our vector layer, which will request data from a URL.

There are two caveats to this example. The first is that it assumes you have a file called ex5_data.json in the same directory as your map file. You can find it in this book's source code files at http://vasir.net/openlayers_book/files/.

Secondly, unless you are running this on a server, it won't work. It will need a proxy host, which we'll cover right after this example. If you do not have access to a server, you can view the example in action at the URL above.

  1. Start a new map file using the base template from Chapter 1. We'll use the Protocol, ...

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