Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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");
                map.addLayer(layer);
                layer = new OpenLayers.Layer.Google( "Google" );
                map.addLayer(layer);

                var jpl_wms = new OpenLayers.Layer.WMS("Administrative Layer",
                "http://localhost:8080/geoserver/test/wms", 
                {layers: "maharashtra_administrative",transparent: true,visibility: false},{isBaseLayer:false});
                map.addLayer(jpl_wms); 
                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.

share|improve this question
    
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
add comment

1 Answer 1

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",
            "http://localhost:8080/geoserver/wms", 
            {layers: "topp:maharashtra_administrative",transparent: true},
            {isBaseLayer:false}
            );

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.

share|improve this answer
    
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? –  iant 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 –  iant Apr 2 '12 at 15:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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