Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am displaying an image on a map in OpenLayers. The problem is: if I zoom out, the image vanishes. If I zoom in, it works as it should. How do I display an image layer in OpenLayers so that when I zoom out, the image is still there? I guarantee this is a duplicate question but I can't seem to find the answer. So, I apologize if this has been answered.

Here is my code:

  var graphic = new OpenLayers.Layer.Image(
                Monocle.currentWidget.name + " Destination " + featurenum,
                "data:image/png;base64," + results,
                new OpenLayers.Bounds(Monocle.Sightline.BBOX(feature,1), Monocle.Sightline.BBOX(feature,2), Monocle.Sightline.BBOX(feature,3),Monocle.Sightline.BBOX(feature,4)),
                new OpenLayers.Size(580, 288),
                { isBaseLayer: false,
                    opacity: 0.3,
                    displayOutsideMaxExtent: true
                });
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You declare a max resolution and then it will resize the image. So, I changed my code to:

var graphic = new OpenLayers.Layer.Image(
                Monocle.currentWidget.name + " Destination " + featurenum,
                "data:image/png;base64," + results,
                new OpenLayers.Bounds(Monocle.Sightline.BBOX(feature,1), Monocle.Sightline.BBOX(feature,2), Monocle.Sightline.BBOX(feature,3),Monocle.Sightline.BBOX(feature,4)),
                new OpenLayers.Size(580, 288),
                { isBaseLayer: false,
                    opacity: 0.3,
                    transitionEffect:'resize',
                    maxResolution: .625,
                    displayOutsideMaxExtent: true
                });
share|improve this answer
add comment

Your Answer

 
discard

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.