[MapServer-users] different shapefiles but same render

mathias cunault mathias.cunault at inrap.fr
Tue Jul 15 23:14:18 PDT 2025


Mapserver 7.6 & OpenLayers 10

My mapfile has to layers from 2 shapefiles :
WEB
METADATA
"wms_title" "WMS-Inrap, natura 2000"
"wms_onlineresource" "
http://caviar.inrap.fr/cgi-bin/mapserv.exe?MAP=C:/ms4w/Apache/site/mapfile/fond_iliad_natura.map
"
"wms_enable_request" "*" #active les getcapabilities, getmap,
getfeatureinfo, getfeature
"wms_srs" "EPSG:3857 EPSG:2154 EPSG:900913"
"wms_encoding" "UTF8"
"ows_enable_request" "*"
END
END
LAYER
NAME "znieff1_metropole"
TYPE POLYGON
STATUS DEFAULT
OPACITY 30
DATA "./ressources_couches/ZNIEFF/znieff1.shp"
PROJECTION
"init=epsg:2154"
END #fin projection
#MAXSCALEDENOM 100000
LABELITEM "etiquette"
CLASS
NAME "znieff1" #apparait en legende
STYLE
COLOR 255 0 0
OUTLINECOLOR 255 240 140
WIDTH 0.5
END #end STYLE
LABEL #apparait pour chaque entité sur la carte
FONT "DejaVu_bold"
COLOR 255 240 140
OUTLINECOLOR 0 0 0
OUTLINEWIDTH 0.5
POSITION cc
SIZE 9
TYPE TRUETYPE
SHADOWCOLOR 100 100 100
MAXSCALEDENOM 60000 #apparait à partir de 1/
MINSCALEDENOM 7000 #apparait jusqu'à 1/
END #ENd label
END # end class
METADATA
"wms_title" "znieff1"
"wms_srs" "EPSG:3857 EPSG:2154"
   END #fin metadata
END #end layer

#-----debut layer znieff2
LAYER
NAME "znieff2_metropole"
TYPE POLYGON
STATUS DEFAULT
OPACITY 30
DATA "./ressources_couches/ZNIEFF/znieff2.shp"
PROJECTION
"init=epsg:2154"
END #fin projection
# MAXSCALEDENOM 100000
LABELITEM "NOM"
CLASS
NAME "znieff2" #apparait en legende
STYLE
COLOR 255 0 250
OUTLINECOLOR 255 0 250
WIDTH 0.5
END #end STYLE
LABEL #apparait pour chaque entité sur la carte
FONT "DejaVu_bold"
COLOR 255 240 140
OUTLINECOLOR 0 0 0
OUTLINEWIDTH 0.5
POSITION cc
SIZE 9
TYPE TRUETYPE
SHADOWCOLOR 100 100 100
MAXSCALEDENOM 60000 #apparait à partir de 1/
MINSCALEDENOM 7000 #apparait jusqu'à 1/
END #ENd label
END # end class
METADATA
"wms_title" "znieff2"
"wms_srs" "EPSG:3857 EPSG:2154"
   END #fin metadata
End #end layer

In Openlayers, I have defined two sources and two layers, example :
const sourceWMSznieff1 = new ImageWMS({
  // serverType: "mapserver",
  projection: "EPSG:3857",
  params: {
    LAYERS: "znieff1_metropole",
    // _t: Date.now(),
  },
  url: "http://
.../mapserv.exe?MAP=C:/ms4w/Apache/site/mapfile/fond_iliad_natura.map&",
})

export const coucheWMSznieff1 = new ImageLayer({
  title: "znieff1",
  source: sourceWMSznieff1,
})

Only LAYERS and title are changing for the second source and layer Image.
In my browser, layers are different, i.e. they display their own datas,
only when I am loading just one.
But loaded together the two layers render the total features of the 2
shapefiles, so in a way the layers are duplicates.

Does it mean I have to create a mapfile for each shapefile ? (it seems
weird to me and I have many shapefile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20250716/39c7d2e6/attachment.htm>


More information about the MapServer-users mailing list