Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that in OpenLayers you can add Features to a Vector Layer which each have image but then they will not scale (i.e. their size stays the same independent of the current zoom) or at least I do not know how to make them scale. For example:

            var vectorLayer = new OpenLayers.Layer.Vector("Overlay");
            var feature = new OpenLayers.Feature.Vector(
            new OpenLayers.Geometry.Point(0,0)
            .transform(projWGS84, map.getProjectionObject()), 
            {externalGraphic: '', graphicHeight: 30,graphicWidth: 30});
            var feature2 = new OpenLayers.Feature.Vector(
            new OpenLayers.Geometry.Point(1,1)
            .transform(projWGS84, map.getProjectionObject()), 
            {externalGraphic: '', graphicHeight: 30,graphicWidth: 30});

On the other hand the scaling of image works fine if you set an image for an Image Layer but then you can have only a single image in a layer.

            var options = {   
                opacity: 1.0, 
                isBaseLayer: false,
                numZoomLevels: 20,
                transparent: 'true'
            var extent = new OpenLayers.Bounds(WEST,SOUTH,EAST,NORTH)
                .transform(projWGS84, map.getProjectionObject());                    
            var gO = new OpenLayers.Layer.Image('Image',
                new OpenLayers.Size(1,1),

My question is: How to have, in OpenLayers, many images on a single layer that will scale as in the above case?

share|improve this question

I would use style's context object which calculates graphicWidth and graphicHeight depending on current map resolution. It applies to you first option (Vector layer).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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