如何向OpenLayers地图添加许多点

时间:2013-09-08 05:46:46

标签: javascript map openlayers gwt-openlayers

我想在OpenLayers地图上的一个图层上显示大约50,000个点。每个点约100公里* 100公里。换句话说,我想在179.3333,65.5000处为100KM * 100KM的盒子上色。我在OpenLayers网站上在线发现了这个教程: http://openlayers.org/dev/examples/styles-context.html

但这不是我想要的。有谁知道任何可以帮助我的教程或文章?或者有关如何做到这一点的任何指示?

此外,如果您认为Openlayers不是正确的工具,而且有更好的工具可以请让我知道吗?

谢谢

1 个答案:

答案 0 :(得分:0)

您想展示个别积分,还是想展示一个大盒子?

显示50,000点会很多,如果缩小远,使用某些群集算法可能会很聪明,请参阅http://openlayers.org/dev/examples/strategy-cluster-threshold.html

添加一个框只需要将多边形添加到矢量图层,请参阅http://openlayers.org/dev/examples/boxes-vector.html

在你的情况下,它可能是这样的:

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();

然后,找出一种方法来定义100x100公里(我的0.3度不会做),并将一个样式图添加到矢量图层