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 – using the Format and Strategy classes alone

Let's take a look at another example now. Here, we'll do something very similar to what we did in the first example—this time, however, we won't use the Protocol. Instead, we'll read in feature data as a JavaScript object and, using the GeoJSON Format class, read in the data. This way, this example will work without having to use a server or proxy host.

  1. Create a new page using the template in Chapter 1. We'll be doing three things here—creating some feature data in GeoJSON format, creating a vector layer, and loading the GeoJSON data into it. Let's create some basic feature data. Feel free to play around with the coordinates and amount of features here:
    var feature_data = { "type": "FeatureCollection", ...

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