0
votes

I am working on a web application based on OpenLayers, Geoserver, Java and JavaScript.

The user needs to select an area on the map and that portion has to be downloaded as an image. I tried hitting the WMS using Ajax -

http://localhost:8080/geoserver/wms?request=GetMap&service=WMS&version=1.1.0&layers=geoworkspace:STRUCTURE,&styles=&srs=EPSG:27700&bbox=526274.1873390013,196214.08896841796,526277.1040062243,196217.2973028639&width=1200&height=1200&format_options=dpi:300;antialiasing:on&format=image%2Fpng8

As a result, I get all the required layers except for the underlying base map. Is there a way to get the base map too?

Is there an alternative approach to this requirement?

2
Where is your base map? - Ian Turton
If the basemap and structure layer are on the same server, then, if you want to show the basemap and a layer on top then just provide a list of layers in the Layers=& attribute - user27874

2 Answers

0
votes

If your base layer is on the same server then you can request it in a single GetMap operation, by providing the layer name in a comma separated list as part of the layers request parameter. Note though that this creates a single image, that merges the layers, so you'll need to take care of the order you list the layers.

So

http://ogc2.bgs.ac.uk/cgi-bin/UGA_ARGI/ows?service=WMS&version=1.3.0&request=GetMap&width=700&height=450&styles=,&layers=ARTISAN,ARTISANC&format=application/openlayers&crs=EPSG:4326&bbox=-2.000000,29.000000,4.500000,37.000000&

The ARTISANC layer is drawn on top of the ARTISAN layer.

and

http://ogc2.bgs.ac.uk/cgi-bin/UGA_ARGI/ows?service=WMS&version=1.3.0&request=GetMap&width=700&height=450&styles=,&layers=ARTISANC,ARTISAN&format=application/openlayers&crs=EPSG:4326&bbox=-2.000000,29.000000,4.500000,37.000000&

The ARTISAN layer is drawn on top of the ARTISANC layer.

So in your case you'd want the base layer to be listed first.

Also note that as you have two layers, you should have two styles, so we have the styles request parameter like styles=,& or you could just have styles& to force the default.