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 – figuring out logical filters

In this example, we'll use a few logical filters and some random points with random population and settlement_type values.

  1. Add in a WMS and vector layer.
            vector_layer = new OpenLayers.Layer.Vector('Basic Vector Layer'); 
            map.addLayer(vector_layer);
  2. Now, we'll need to create an anonymous object containing some settlement value that we'll pick from at random:
    var settlement_values = { 
        0: 'village', 
        1: 'city', 
    }
  3. Let's create some feature. We'll create twenty features, using some random population and settle_type values in each feature's attribute property:
    for(var i=0; i<20; i++){ vector_layer.addFeatures([new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point( (Math.floor(Math.random() * 360) - 180), ...

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