[OpenLayers-Users] ClusterStrategy Problem
Dresel
dresel at gmx.at
Fri Aug 7 16:08:51 EDT 2009
Hi,
i want to use ClusterStrategy with VectorLayer. My Layer is generated like
this:
<html>
<head>
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
data = new Array();
for (var i = 0; i < 10; i++)
{
data[i] = new Array();
data[i][0] = Math.random() * 5;
data[i][1] = Math.random() * 5;
}
//Vectorlayer
var vectorLayer = new OpenLayers.Layer.Vector(
"Linien",
{
});
for(key in data)
{
var point = new OpenLayers.Geometry.Point(data[key][0],
data[key][1]);
vectorLayer.addFeatures(new OpenLayers.Feature.Vector(point));
}
map.addLayer(vectorLayer);
vectorLayer.refresh();
</script>
</body>
</html>
This works, points are drawn. Now i add a stylemap and the ClusterStrategy
(from the ClusterExample):
<html>
<head>
<title>OpenLayers Example</title>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
map.zoomToMaxExtent();
data = new Array();
for (var i = 0; i < 10; i++)
{
data[i] = new Array();
data[i][0] = Math.random() * 5;
data[i][1] = Math.random() * 5;
}
var style = new OpenLayers.Style({
pointRadius: "${radius}",
fillColor: "#ffcc66",
fillOpacity: 0.8,
strokeColor: "#cc6633",
strokeWidth: 2,
strokeOpacity: 0.8
}, {
context: {
radius: function(feature)
{
return Math.min(feature.attributes.count, 7) + 3;
}
}
});
//Vectorlayer
var vectorLayer = new OpenLayers.Layer.Vector(
"Linien",
{
strategies: [
new OpenLayers.Strategy.Cluster()
],
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": {
fillColor: "#8aeeef",
strokeColor: "#32a8a9"
}
})
});
for(key in data)
{
var point = new OpenLayers.Geometry.Point(data[key][0],
data[key][1]);
vectorLayer.addFeatures(new OpenLayers.Feature.Vector(point));
}
map.addLayer(vectorLayer);
vectorLayer.refresh();
</script>
</body>
</html>
This doesn't show any points at all. What did i do wrong?
Thanks for help,
Dresel
--
View this message in context: http://n2.nabble.com/ClusterStrategy-Problem-tp3406487p3406487.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list