0

So trying to work through the setup of geoserver and using an example script see below.

<!DOCTYPE html> <html> <head> <title>Simple Map</title> <link rel="stylesheet" href="http://openlayers.org/en/v3.15.1/css/ol.css" type="text/css"> <script src="http://openlayers.org/en/v3.15.1/build/ol.js"></script> </head> <body> <div id="map" class="map"></div> <script> var layers = [ new ol.layer.Tile({ source: new ol.source.MapQuest({layer: 'osm'}) }), new ol.layer.Tile({ extent: [-13884991, 2870341, -7455066, 6338219], source: new ol.source.TileWMS({ url: 'http://localhost:8080/geoserver/cite/wms', params: {'LAYERS': 'topp:states', 'TILED': true}, serverType: 'geoserver' }) }) ]; var map = new ol.Map({ layers: layers, target: 'map', view: new ol.View({ center: [-10997148, 4569099], zoom: 4 }) }); </script> </body> </html>

When opening the page though i cannot see the sample shapefiles 'topp:states' Anyone know what i am doing wrong?

I assume i have something wrong with the URL for the source.

4
  • 2
    Is topp:states published in the geoserver/cite/wms endpoint?
    – user30184
    Commented May 5, 2016 at 7:40
  • not sure, how would i check? thanks for the reply
    – cmca
    Commented May 5, 2016 at 7:42
  • Try to modify the call to your wms layer this way: new ol.layer.Image (instead of Tile), new ol.source.ImageWMS (instead of TileWMS), add 'FORMAT': 'image/png' in the params
    – Vale
    Commented May 5, 2016 at 7:49
  • To check you would use a GetCapabilities request, like http://localhost:8080/geoserver/cite/wms?request=GetCapabilities&service=WMS&
    – nmtoken
    Commented Jun 27, 2016 at 10:54

1 Answer 1

1

Figured out the issue. The URL was wrong instead of it being

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

it should have been

http://localhost:8080/geoserver/wms
1
  • To add a bit of information: Your original URL tried to load topp:states in the cite namespace while it is part of the topp namespace. Commented May 5, 2016 at 8:26

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