[OpenLayers-Users] Need help for Cluster strategy using externalGraphic
Xavier Mamano (jorix)
xavier.mamano at gmail.com
Sat Mar 2 12:08:17 PST 2013
Hi,
Try:
var myClusterStyleMap = new OpenLayers.StyleMap({
'default': new OpenLayers.Style({
externalGraphic: 'http://openlayers.org/dev/img/marker.png',
graphicWith: 21,
graphicHeight: 25,
label: '${count}',
labelOutlineColor: "#aaaaaa",
labelOutlineWidth: 2
}, {
context: {
count: function(feature) {
if (feature.cluster) { // is `.cluster` the array of
clustered features
return feature.cluster.length; // or
feature.attributes.count, is the same
} else { // is not clustered
return ''; // no label
}
}
}
})
});
kml_layer = new OpenLayers.Layer.Vector("KML", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed(),
new OpenLayers.Strategy.CenteredCluster({threshold: 2 // to
display single cluster as feature
})
],
styleMap: myClusterStyleMap,
protocol: new OpenLayers.Protocol.HTTP({
url: filename,
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true,
maxDepth: 3
})
})
});
Now I have put everything you need, including `new` I neglected ;-) ...and
now is tested.
NOTE: When extracting uses "extractStyles: true" features ignore the layer
styles, so is not necessary '${myGrafic}' if uses "threshold: 2".
Xavier Mamano
robertico wrote
> I tried your example but no luck so far.
> <br>
> I've added the strategy;
> <br>
> And
/
> myClusterStyleMap
/
> ;
> <br>
> <br>
> <br>
> <br>
> No markers at all. Only the map
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Need-help-for-Cluster-strategy-using-externalGraphic-tp5037985p5038013.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list