I have a html page with 2 WMS layers.
The first is one Base Layer , & the second is my personal WMS feature. I load it from Geoserver. The problem when I add the 2 layers I do not have the superposition
The problem is maybe on the projection. please can you help me this is my code
<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
var map;
OpenLayers.ProxyHost = "/cgi-bin/proxy.cgi?url=";
var host = "http://'my_host':8080/geoserver/wms";
function init() {
map = new OpenLayers.Map('map', {
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher({'ascending':false}),
new OpenLayers.Control.ScaleLine(),
new OpenLayers.Control.MousePosition()]});
var reg = new OpenLayers.Layer.WMS(
"Région",
host,
{layers: 'cite:matregion_view', format: 'image/gif',transparent: true}
);
var gmap = new OpenLayers.Layer.Google(
"Google Streets", // the default
{numZoomLevels: 20}
);
map.addLayers([gmap , reg]);
//map.setCenter(new OpenLayers.LonLat(146.7, -41.8), 6);
map.zoomToExtent(new OpenLayers.Bounds(-16.884,20.748,-1.026,35.924));
}
Best Answer
To overlay the custom WMS layer correctly, I would first set the projection of the map, by passing in the projection parameter, and then at the end I would set the bounds in this projection.
My code would be as follows: