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", 
                {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?


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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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