[OpenLayers-Users] Superimpose an image layer to another layer

Andreas Hocevar ahocevar at opengeo.org
Wed Dec 16 13:47:02 EST 2009


Hi,

jpeg  images do not support transparency. Use gif or png instead, and
make sure that the background of your image is really transparent.

Regards,
Andreas.

On 2009-12-16 17:56, Stefano Piazza wrote:
> Hello guys,
>
> I'm trying to enhance the information of a Layer.Google element with
> an Image Layer.
> The goal is to display the project of a building over the google layer.
> I thought the best way to do it was using a Layer.Image, but AFAICS
> when the image is visible all the space left free from the image is
> filled with a white opaque color instead of being transparent, so the
> google layer behind is not visible.
> I checked the examples and documentation but I cannot find a solution.
> Do you have any idea?
> Or maybe Openlayers API provide a better way to do what I want?
> Here is the code, thank you:
>
> --------------------------------------------------------------------------- CODE
> var options = {
>   projection: new OpenLayers.Projection("EPSG:900913"),
>   displayProjection: new OpenLayers.Projection("EPSG:4326"),
>   units: "m",
>   numZoomLevels: 18,
>   maxResolution: 156543.0339,
>   visibility: true,
>   maxExtent: new OpenLayers.Bounds(10, 10, -10, -10)
> };
>
> map = new OpenLayers.Map('map');
>
> // creating layers
> var customImage = new OpenLayers.Layer.Image('Map', 'image.jpg', new
> OpenLayers.Bounds(10 ,10, -10, -10   ), new OpenLayers.Size(437, 300),
> this.options);
> var gmap = new OpenLayers.Layer.Google("Google Streets",
> {'sphericalMercator': true});
>
> //adding to map
> map.addLayers([gmap, customImage]);
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> if (!map.getCenter()) {
>     map.zoomToMaxExtent()
> }
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list