[OpenLayers-Users] Clustering De-Serialized GeoJSON Feature Collection

rickm81 rickm81 at yahoo.com
Mon Aug 12 06:23:20 PDT 2013


Hello,

I've been having some trouble using the cluster strategy. 

I would like to apply the strategy without setting a protocol on my layer.
To do this I first created my cluster strategy, then the vector layer, then
read in the GeoJSON Feature Collection and added it to the layer, and
finally tried activating the strategy. The Feature Collection shows up on
the map, but the clustering is never applied. I've included the code below:

var clusterStrategy = new OpenLayers.Strategy.Cluster({ distance: 20 });

// Add Feature Locations
var format_geojson = new OpenLayers.Format.GeoJSON({
     'internalProjection': new OpenLayers.Projection("EPSG:900913"),
     'externalProjection': new OpenLayers.Projection("EPSG:4326")
     });

vectorLayer = new OpenLayers.Layer.Vector('Feature Locations', { projection:
wgs84, strategies:  [clusterStrategy] });

vectorLayer.addFeatures(format_geojson.read(geojsonstring));

clusterStrategy.activate();

So basically, I'm passing a serialized GeoJson string into a Javascript
function, adding the GeoJSON features to the map, and failing to cluster
them. If anyone has tried doing the same and can recommend how to accomplish
this I would be happy to hear. Thank you!

-Rick




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Clustering-De-Serialized-GeoJSON-Feature-Collection-tp5072067.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list