0

I am displaying icon in feature. I want the size of icon to be dependent to zoom level of map i.e. the icon appears smaller in low zoom levels and bigger in high zoom levels. i used stylemap for that but the icon size does not change on zoom change.

var styleschool = new OpenLayers.Style({
            pointRadius: "${radius}",
            label:"${name}",
            fillOpacity: 0.7,
            fillColor:'blue',
            strokeColor:'blue',
            fontcolor:'blue',
            externalGraphic:'icon/school_color_icon.png'
        },
        {
            context:{
                radius: function(feature){
                    return map.getZoom()*0.9;
                }
            }
        })

1 Answer 1

2

pointRadius doesn't affect size of externalGraphic, you have to set graphicWidth and graphicHeight instead, try:

graphicWidth: "${radius}",
graphicHeight: "${radius}",
...

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.