0

I have a polygon layer stored as a table within PostGIS/PostgreSQL using SRID 3857. I have created a MapServer layer pointing to this layer. However, when I try to load this layer into Leaflet as a WMS using the L.tileLayer.wms() function it only comes up as a white blank PNG over the default Leafet map area. I am pretty sure I am passing in a correct bounding box for the SRID 3857 coordinates. Here is a code snippit of what I am doing:

var map = L.map('map').setView([30.35792, -87.17677], 14);

L.tileLayer('http://localhost:8080/cgi-bin/mapserv.exe?map=C:/OSGeo4W/apps/gbp/gbp.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=parcels3857&STYLES=&SRS=EPSG:3857&BBOX=-31856626.987,11633877.801,-31821383.931,11657185.093&WIDTH=400&HEIGHT=300&FORMAT=image/png', {
    maxZoom: 18,
    layers: 'parcels',
    attribution: 'GBP Parcels'
}).addTo(map);

And my map file layer configuration:

  LAYER 
    NAME "parcels3857"
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 port=5432 dbname=gbp user=abc password=xyz"
    DATA "geom FROM parcels"

    PROJECTION
        "init=epsg:3857"
    END
    METADATA
        "wms_title" "parcels3857"
    END
    STATUS       on

    STATUS DEFAULT
    TYPE POLYGON
    CLASS
      NAME "parcels3857"    
      STYLE
        COLOR 227 227 127
      END
    END
  END  

Why does the layer only show up as a white PNG?

2

Let me copy-paste from the Leaflet tutorial on WMS:

The base WMS URL is simply the GetCapabilities URL, without any parameters

Do not add any other parameters to the base URL. If you need extra parameters, pass more options to the L.TileLayer.WMS constructor instead.

Judging by your code, I'll bet that the URLs actually requested have duplicated parameters, and your WMS server is being confused by that. Press F12 in your browser and use the network inspector to see what's going on and the actual URLs being requested.

  • Thanks Ivan. You were spot-on. If I setup the call with the single parameters of layers it works like a champ. – geo derek Jul 15 '16 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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