Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • OpenLayers 2.10 Beginner's Guide
  • Toc
  • feedback
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)
close
OpenLayers 2.10 Beginner's Guide

OpenLayers 2.10 Beginner's Guide

4.2 (9)

Overview of this book

Table of Contents (18 chapters)
close
OpenLayers 2.10
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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), 
                (Math.floor(Math.random() * 180) - 90) 
            ), 
            { 
                 'population': Math.floor(Math.random() * 2000), 
          'settlement_type': settlement_values[(Math.floor...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete