Question

I want to show around 50,000 points on a layer on OpenLayers map. Each point is around 100 KM * 100 KM. In other words, I would like to color a 100KM * 100KM box green at 179.3333,65.5000. I found this tutorial online on the OpenLayers website: http://openlayers.org/dev/examples/styles-context.html

But that is not what I'm looking for. Does anyone know any tutorials or articles that can help me out? or any pointers on how to do that?

Moreover, if you think Openlayers is not the right tool and there is a better one could you please let me know?

Thank you

Was it helpful?

Solution

Do you want to show individual points, or do you want to show a large box?

Showing 50,000 points would be a lot, and it might be smart to use some cluster algorithm if you zoom out far, see http://openlayers.org/dev/examples/strategy-cluster-threshold.html

Adding a box would just be a matter of adding a Polygon to a Vector layer, see http://openlayers.org/dev/examples/boxes-vector.html

In your case, it could be something like:

var map = new OpenLayers.Map('map');
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                "http://vmap0.tiles.osgeo.org/wms/vmap0?", {layers: 'basic'} );
var boxes  = new OpenLayers.Layer.Vector( "Boxes" );
var center = OpenLayers.Geometry.Point(179.3333,65.5000);
var bounds = OpenLayers.Geometry.Polygon.createRegularPolygon(center, 0.3, 4, 0);
var box = new OpenLayers.Feature.Vector(bounds.toGeometry());
boxes.addFeatures(box);

map.addLayers([ol_wms, boxes]);
map.zoomToMaxExtent();

Then, figure out a way to define 100x100 kilometres (my 0.3 degrees will not do), and add a stylemap to the vector layer

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top