I am using OSM/Google maps and WMS Layers. Now I want to know how my WMS will overlay on this map. I am using the following code for that:

function init()
                map = new OpenLayers.Map('map');

                layer = new OpenLayers.Layer.OSM( "OpenStreet Map");
                layer = new OpenLayers.Layer.Google( "Google" );

                var jpl_wms = new OpenLayers.Layer.WMS("Administrative Layer",
                {layers: "maharashtra_administrative",transparent: true,visibility: false},{isBaseLayer:false});
                map.addControl(new OpenLayers.Control.LayerSwitcher());
                map.setCenter(new OpenLayers.LonLat(8461018,2120810),6.75);
                map.addControl(new OpenLayers.Control.MousePosition({}));
                map.addControl(new OpenLayers.Control.OverviewMap());
                map.addControl(new OpenLayers.Control.ScaleLine());

Can anybody guide me for the same as this overlay does not appear in the map.

  • Use different names for your map layers. Your OSM layer and Google layer names are the same. Again your google layer definition is not correct. you have to define the type of google map layer, eg. Google Streets (default one), google.maps.MapTypeId.HYBRID and etc. For your own WMS layer, what projection you are using? May be you will have to reproject it yourself or tell Openlayers to do the same on the fly. Go through openlayers.org/dev/examples – thelastray Mar 30 '12 at 6:31

The parameter

visibility: false 

looks problematic to me. It's in the wrong place and will prevent your layer showing if it is in the right place.

Try something like:

var jpl_wms = new OpenLayers.Layer.WMS("Administrative Layer",
            {layers: "topp:maharashtra_administrative",transparent: true},

Note I've assumed that you have placed your layer in the topp name space - you'd need to change that if you have created and used your own workspace.

  • Boss it active but not displayed on osm Layer – Pari Mar 30 '12 at 10:20
  • 3
    look in the network tab of firebug and check if the url generated by the request actually gets an image? – Ian Turton Mar 30 '12 at 10:27
  • No it is comming – Pari Apr 2 '12 at 12:01
  • I don't understand - do you get an image when you look at the link in firebug? if yes then your projection or bounding box may be wrong. if no then something is wrong with your server or your request – Ian Turton Apr 2 '12 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.