0

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

Farshad Momtaz
  • 424
  • 1
  • 8
  • 22

1 Answers1

0

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

ivy
  • 5,539
  • 1
  • 34
  • 48
  • Thank you for your answer. I'm mainly trying to create something like [link](http://sac.csic.es/spei/map/maps.html) In other words i have a list of different lat and lon s and want to show different colors, which indicate different information, on the map. Should I use the cluster strategy, should i create the map using php (with a different tool) and use a layer to show those data, or should I just use points? Thank you – Farshad Momtaz Sep 08 '13 at 23:28
  • 1
    Ah, now I get it. Like a weather map. You should not do this with a vector layer, but with a semi-transparant image layer. You could use a single static image if your data is static (see http://openlayers.org/dev/examples/image-layer.html ), generate the image (e.g. a png) with php if it's dynamic. More advanced would be to use somehting like geoserver to generate tiles on different zoomlayers. – ivy Sep 09 '13 at 07:15
  • I'm currently using the method you mentioned. I have problems with the zoomlayers because they have low quality. So I decided to add in the points manually using openlayers vectors so it has better quality. Should I just use the Geoserver to create the smaller layers and layover the smaller ones for the zoom? Btw, if you are aware of any tutorial sources I would appreciate it if you can share them. Thank you – Farshad Momtaz Sep 09 '13 at 08:29
  • I found [this tutorial](http://blog.mikecouturier.com/2011/07/create-zoomable-images-using-google.html) that explains what to do when using Google Maps. I think I can use the same info for the Open Layers – Farshad Momtaz Sep 10 '13 at 19:57