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'm a total n00b with GeoServer. I've installed it and have loaded a sample shapefile, which I can view using the Layer Preview option.

enter image description here

Now I want to add this shapefile (as a WMS layer) to a simple OpenLayers map using the methodology listed at http://dev.openlayers.org/docs/files/OpenLayers/Layer/WMS-js.html:

var wms = new OpenLayers.Layer.WMS("NASA Global Mosaic",
    "http://wms.jpl.nasa.gov/wms.cgi",
    {
    layers: "modis,global_mosaic",
    transparent: true
    }, {
    opacity: 0.5,
    singleTile: true
}); 

How do I find the URL which corresponds to one of the layers in the screenshot above?

If I use the Preview Layer option and choose JPG as the format, the URL is in the form:

http://localhost:8080/geoserver/cite/wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:States2006 ... rather than the /wms.cgi form listed above.

Thanks for any advice on getting started with GeoServer and OpenLayers.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The short answer is

http://localhost:8080/geoserver/cite/wms

The longer answer is that the URL in OpenLayers is the base URL of the web map server (so all the bit before the ? in the full URL). OpenLayers then adds the required parameters to make up the URL that is required to get a map. Some of those parameters are added from your layer definition (i.e. layers, transparent etc) and others from the map object (i.e. width/height and bounding box). See Lesson 8 of my old course to see a fuller discussion.

share|improve this answer
    
That's an excellent resource - thanks for sharing! –  Stephen Lead Mar 8 '12 at 22:44

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.