2

I would like to understand why I cannot view or see the WMS layers loaded. Based on the investigation I did so far, I am assuming this has to do with base layers projections. My overlays are WGS84, EPSG 4326. Any guidance on how to resolve this?

This is what I currently see: enter image description here

    <script>
      //Base Layers
      var OSM = L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',
        maxZoom: 18
      });

      var Esri_WorldImagery = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
    attribution: 'Tiles &copy; Esri &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
 });

      var uis_erven = new L.tileLayer.wms("http://localhost:8080/geoserver/Erongo/wms", "Erongo:uis_erven", {
        layers: 'uis_erven',
        format: 'image/png',
        transparent: true,
        attribution: '',
      });

      var uis_erven_layout = new L.tileLayer.wms("http://localhost:8080/geoserver/Erongo/wms", "Erongo:uis_erven_layout", {
        layers: 'uis_erven_layout',
        format: 'image/png',
        transparent: true,
        attribution: '',
      });

      //create the map
      var map = L.map('map', {
        zoomControl:true,
        zoom: 14,
        maxZoom:18,
        minZoom:5,
        center: new L.LatLng(-21.2531795501709, 14.8524971008301),
        fullscreenControl: true,
        layers: [OSM, uis_erven, uis_erven_layout]
      });
      //layer control
      var baseMaps = {
        "OpenStreetMap": OSM,
        "ESRI  World Imnagery": Esri_WorldImagery
      };
      var overlayMaps = {
        "Zonning": uis_erven,
        "Erven Layout": uis_erven_layout,
      };
      L.control.layers(baseMaps, overlayMaps).addTo(map);

    </script>
  </body>

</html>
6
  • 1
    look in the browser JS debugger and see what is returned in the "images" from GeoServer - it is likely to be the error message
    – Ian Turton
    Commented Nov 18, 2019 at 14:19
  • 1
    if you look for the WMS images and check the preview I think you will see error messages in the images
    – Ian Turton
    Commented Nov 18, 2019 at 14:36
  • <?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE ServiceExceptionReport SYSTEM "localhost:8080/geoserver/schemas/wms/1.1.1/…"> <ServiceExceptionReport version="1.1.1" > <ServiceException code="org.geoserver.wms.map.GetMapKvpRequestReader"> No LAYERS has been requested </ServiceException></ServiceExceptionReport> Commented Nov 18, 2019 at 14:46
  • 1
    You posted it while I was typing and so I didn't see it. Please take a look at the WMS request that goes to server and add it to your question. And one thing more: you have second parameter "Erongo:uis_erven_layout" in your WMS call. There is no such parameter in Leaflet docs: leafletjs.com/reference-1.6.0.html#tilelayer-wms
    – TomazicM
    Commented Nov 18, 2019 at 14:57
  • 1
    OK now we need to examine the URL that is generating that error, does it have a LAYERS= parameter (because GeoServer doesn't think so).
    – Ian Turton
    Commented Nov 18, 2019 at 15:09

1 Answer 1

2

As the error returned by GeoServer says there are no layers in the request you are making, so no map gets drawn. Looking at the Leaflet manual suggests that you need to provide an options object with the layers parameter in it. So something like this should work:

var uis_erven = new L.tileLayer.wms("http://localhost:8080/geoserver/Erongo/wms", {
        layers: "Erongo:uis_erven",
      });

None of your other options were necessary as I think they are all the default anyway, you can add them back if you need.

3
  • Success, thank you so much Ian Turton. Commented Nov 18, 2019 at 15:45
  • @AmeliaNicodemus If answer helped you solve your problem, you should mark it as accepted, not only upvote it.
    – TomazicM
    Commented Nov 18, 2019 at 16:39
  • @TomazicM noted. Commented Nov 18, 2019 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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