[OpenLayers-Users] clustering strategy problem in 900913 projection

AlexR alexrushforth at hotmail.com
Sun Apr 17 06:47:19 EDT 2011


I'm trying to set up a clustering strategy for a vector layer, but since
changing my app from using a 4326 to a 900913 projection can't seem to get
the clustering to work any more! Where with a 4326 projected map the
clustered points would changed as you zoom in and out I now get a single
clustered point returned each time rather than separate clustered points. 

Here is more info about my app: 

1) The strategy variable for clustering is defined outside of the map onload
function. I'm not sure if the distance property has anything to do with
projection (its in pixels?) but changing this value has no effect on my
problem. 

                strategy = new OpenLayers.Strategy.Cluster(); 
                strategy.distance = 20; 
                //strategy.threshold = 1; 

2) I include the following code within my body onload function to set up the
vector layer where i initialize the map. Set to use the clustering strategy. 

                vector_layer = new OpenLayers.Layer.Vector("Point
Locations", { 
                    preFeatureInsert: preFeatureInsert, //adding this breaks
clustering!?? 
                    strategies: [strategy], 
                    styleMap: new OpenLayers.StyleMap({ 
                        "default": style, 
                        "select": { 
                            fillColor: "#800080", 
                            strokeColor: "#000000" 
                        } 
                    }) 
                }); 

3) the preFeatureInsert function is called to reproject points from 4326 (in
my database) into 900913 (in order to show on map) whenever I add new
locations to my vector layer using the vector_layer.addFeatures(   
function.. 

        function preFeatureInsert(feature) { 
            var src = new OpenLayers.Projection('EPSG:4326'); 
            var dest = new OpenLayers.Projection('EPSG:900913'); 
            feature.geometry.transform(src, dest); 
        } 


I'm not sure if i'm missing something here, but would really appreciate some
help from the experts! many thanks, 
Alex

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/clustering-strategy-problem-in-900913-projection-tp6280745p6280745.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list