2

I am digging into clustering strategies with Open Layers 2. Looking at the example OpenLayers2 Cluster Strategy Threshold, I was able to get it working. Unfortunately I am working with OSM, and the example is not working as expected by replacing the appropriate line in the code example:

 /*var base = new OpenLayers.Layer.WMS("OpenLayers WMS", 
                 "http://vmap0.tiles.osgeo.org/wms/vmap0",
                {layers: 'basic'}
            );
 */
 var base = new OpenLayers.Layers.OSM();

It results in looking at only one circle instead of many. Only when I start zooming in, more and more circles do appear. Why is it different when I am using OSM? Which settings have to be taken care of?

1 Answer 1

1

This happens because the OSM-Layer uses another CRS than the random points. A quick fix is to transform the created points in the corresponding loop:

features.push(new OpenLayers.Feature.Vector(
    new OpenLayers.Geometry.Point(px, py).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:3857")), {x: px, y: py}
));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.