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 Geometry class methods

Let's demonstrate some of the methods we just talked about. These methods can be applied to any geometry subclass—Point, Polygon, etc.

  1. Open up the first example from this chapter. We'll use Firebug again to demonstrate the functions.
  2. Before we can do anything we need some geometry objects. We won't use the Feature class here—we'll just demonstrate some geometry object methods. Because we aren't associating the Geometry objects with Feature objects this time, we won't see anything getting added to the map, as a Geometry object alone is not necessarily tied to any layer or feature. Let's create two geometry point objects with random coordinates:
    var geom_1 = new OpenLayers.Geometry.Point( (Math.floor(Math.random() ...

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