Resizing point on zoom out

Resize Features Programatically using Openlayers v2.12

enter image description here

 map.addLayer(vectorLayer);
        map.setCenter(new OpenLayers.LonLat(point.x, point.y), 5);
        vectorLayer.addFeatures([pointFeature, lineFeature, polygonFeature]);

    }

    var origin = new OpenLayers.Geometry.Point(-111.04, 45.68);
    function resizeFeatures(scale) {
        pointFeature.geometry.resize(scale, origin);
        lineFeature.geometry.resize(scale, origin);
        polygonFeature.geometry.resize(scale, origin);
        vectorLayer.redraw();
    }

http://dev.openlayers.org/releases/OpenLayers-2.12/examples/resize-features.html View>Source


The Resize, as @Mapperz mentioned is probably the way to go.

Alternatively, If you have lots of points, rather than looping through all the points resizing them, you could change the layer's pointRadius style on map zoom so the change happens to all features in one call. I can't say for sure what is better performance, but I would imagine changing the style would if there are many points.

The styling method has drawbacks such as does not have as many options as the Resize does (scale,origin,ratio), it's only a radius.

Here is a DEMO

enter image description here enter image description here

Tags:

Openlayers 2