Hello Mathias, This look rather an Openlayers question: how to create a source and a WMS layer, and change the setting of the latter to change the LAYERS parameter.
> But loaded together the two layers render the total features of the 2 shapefiles, so in a way the layers are duplicates. That's look the expected behavior as Jukka said. The two shapefile are different so they are not duplicated. Y. Le mer. 16 juil. 2025 à 08:14, mathias cunault via MapServer-users < mapserver-users@lists.osgeo.org> a écrit : > 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 > > > _______________________________________________ > MapServer-users mailing list > MapServer-users@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/mapserver-users > -- [image: This is Yves Jacolin's card. Their email is yves.jaco...@camptocamp.com. Their phone number is +33 6 18 75 42 21. Their phone number is +33 4 58 48 20 43. Their phone number is +41 21 619 10 43.] <https://hihello.me/p/c7a536d1-5177-4817-8924-ebb067e58d4f>
_______________________________________________ MapServer-users mailing list MapServer-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users