I need to create a map with two layers. The first layer (basemap) is the OSM layer, and the second layer is my custom GeoServer WMS layer. This layer is in EPSG:4326 projection. Is this possible?
I have read many posts but I didn't solve my problem. I don't find this GeoServer layer in my map.
map = new OpenLayers.Map('map'{projection:"EPSG:900913",
maxResolution:2319.89824519781,
units:'m' });
osm = new OpenLayers.Layer.OSM( "Simple OSM Map");
wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", "95.172.21.2:8080/geoserver/wms";,
{layers: 'asl.caserta:distretti_4326',trasparent: true},
{isBaseLayer: false});
map.addLayers([osm, wms]);
map.setCenter( new OpenLayers.LonLat(14.22231, 41.26700).transform( new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() ), 12 ); –
Best Answer
There are a couple of issues with your code. Firstly, the map was not properly initialized. The Url of WMS service, as well as the
transparent
paramter was incorrect.I have corrected the code. The following works for me: