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 – adding features

Let's add some features to a map manually.

  1. Make a copy of the first example—we'll just need a basic WMS base layer and a vector layer.
  2. Open up the map in Firefox and enable Firebug. We'll use the JavaScript console to add features to the vector layer.
  3. Let's create some features first. To do so, we'll need to make use of the OpenLayers.Geometry classes. Let's start off by creating a OpenLayers.Geometry.Point object, passing in a longitude and latitude (type and execute the following in Firebug):
    var point = new OpenLayers.Geometry.Point(-72, 42);
  4. Now that we have a geometry object, we can create a feature object from it. We'll use the OpenLayers.Feature.Vector class to create a feature object using the point object ...

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