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

Stefano Piazza stefano.piazza at univr.it
Wed Dec 16 11:56:40 EST 2009


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()
}



More information about the Users mailing list