[GIS] Help displaying jpg in OpenLayers

imageopenlayers-2

I am trying to overlay a jpg image over an OpenLayers map. I have been to the example on their site and looked all over for a solution with no luck. So I am guessing that their are rules for setting an openlayers.layer.image as an overlay layer. I have tried jpg, png, gif. They all work fine as a base layer with the following code:

var image_layer = new OpenLayers.Layer.Image( 'Wallpaper', 'images.png', new 
OpenLayers.Bounds(-90,-45,90,45), new OpenLayers.Size(318,159), {numZoomLevels:7,
maxResolution:.625} );

But once I include:

var image_layer = new OpenLayers.Layer.Image( 'Wallpaper', 'images.png', new 
OpenLayers.Bounds(-90,-45,90,45), new OpenLayers.Size(318,159), {numZoomLevels:7, 
maxResolution:.625, **isBaseLayer: false**} );

the layer is grey out within the layer switcher

I did figure out that if I include two different image layers – I can specify the second as an overlay. However, once I add a WMS, that overlay greys out!

What am I doing wrong – or better yet – what is OpenLayers doing wrong?

Best Answer

I use the following code:

  graphic = new OpenLayers.Layer.Image(
            'Viewshed',
            'http://..../image.png',
            new  OpenLayers.Bounds(20.008697509767,32.076110839844,20.123138427735,32.154235839844),
            new OpenLayers.Size(750, 512),
            { isBaseLayer: false,
              opacity: 0.3,
              displayOutsideMaxExtent: true
            }
        );

and it works fine. I assume you do have a base layer of some sort in your map and that you've added it to the map before the image layer?