0

Why won't my MapServer WMS show in Leaflet when I use STATUS ON in my layer in the map file, but when I change to STATUS DEFAULT it does, but all layers are displayed.

LAYER
    NAME Jalan
    DATA mks_road
    METADATA
        WMS_TITLE "jalan"
        WMS_SRS "EPSG:4326"
    END
    STATUS ON
    TYPE LINE
    CLASS
        NAME "Jalan"
        STYLE
            COLOR 185 0 0
        END
    END
END

and my script is:

var mapserver = 'http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/map/leaf.map&'; 
var jalan = new L.tileLayer.wms(mapserver, {
                    layers: 'jalan',
                    format: 'image/png',
                    srs: 'EPSG:4326',
                    transparent: true
                });

i got this statement when i use wms "GetMap" on Mapserver msWMSLoadGetMapParams(): WMS server error. Missing required parameter SRS

4
  • You mention layers (plural) but your example shows only one layer. Dealing on a single layer basis, status default turns the layer on permanently, so MapServer will always send it.
    – nmtoken
    Commented Feb 6, 2017 at 20:00
  • What actual request is sent to the MapServer WMS service? Are you getting any error message?
    – nmtoken
    Commented Feb 6, 2017 at 20:09
  • You set layer title to "jalan" but layer name is "Jalan". Use "Jalan" in GetMap. And in the future, read the GetCapabilities first.
    – user30184
    Commented Feb 6, 2017 at 22:26
  • i got this statement when i use wms "GetMap" on Mapserver msWMSLoadGetMapParams(): WMS server error. Missing required parameter SRS Commented Feb 8, 2017 at 15:24

1 Answer 1

1

You have set Leaflet to ask for layer named "jalan" but the WMS name for that layer is "Jalan". What is used in the WMS GetMap request is the name of the layer, not the title.

You set the name with LAYER - NAME as

NAME Jalan

You set the WMS title in METADATA with

METADATA
WMS_TITLE "jalan"

The reason why the layer shows with the wrong Leaflet configuration is that when you set it to DEFAULT is that all DEFAULT layers are rendered always even if they are not asked with GetMap.

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.