In this example, we'll use a few logical filters and some random points with random population
and settlement_type
values.
Add in a WMS and vector layer.
vector_layer = new OpenLayers.Layer.Vector('Basic Vector Layer'); map.addLayer(vector_layer);
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', }
Let's create some feature. We'll create twenty features, using some random
population
andsettle_type
values in each feature'sattribute
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...