[OpenLayers-Users] clustering strategy problem in 900913 projection

Stephen Woodbridge woodbri at swoodbridge.com
Sun Apr 17 13:08:53 EDT 2011


What does strategy.distance = 20 mean in EPSG:4326 vs EPSG:900913?
Is distance in units of the layer or in some fixed distance units like 
meters regardless of the layer projection?

What happened if you change 20 to 2220895 in your 900913 map? Which is 
20*69*1609.344 to approximate 20 degrees in meters.

I'm just guessing, reading some of the OL code would probably reveal the 
answer.

-Steve

On 4/17/2011 6:47 AM, AlexR wrote:
> 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.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list