[MAPSERVER-USERS] Dynamic Style rendering for MapServer WMS

Milo van der Linden mlinden at zeelandnet.nl
Tue Mar 4 00:49:35 PST 2008


D_Guidi schreef:
>  I'm relatively new to mapserver, but I've created a WMS service with
>  MapServer that publish SDE data in a fashion way and with a great
>  speed.
>  I'm using this WMS to publish my data via a webapp using OpenLayers,
>  and I want to make better my website trying to change dynamically the
>  style of my WMS maps...
>  The goal is to do this:
>  When the user query the data via getfeatureinfo, I want to reload the
>  image and show with a different color the feature queried.
>  With getfeatureinfo i could retrieve the ID of the selected feature,
>  so I need to change dynamically the STYLE definition of my mafile, or
>  something like this... any suggestion or a link to start reading docs
>  on how to do this?
>  Thanks :)
>  Diego Guidi
>
>   
In the mapfile, add a copy definition of the layer you want to highlight

LAYER
  NAME 'ps_highlight'
  TRANSPARENCY 100
  DUMP TRUE

    TYPE POLYGON
    DATA 'E:\mapdata\my_original_layer.shp'
    METADATA
      "ows_title" "ps_highlight"
      "ows_srs" "EPSG:4326"
    "gml_featureid" "id"
    END
    STATUS OFF
    PROJECTION
     "init=epsg:4326"
    END
    MAXSCALE 100000
    CLASSITEM 'ID'
    CLASS
       #NAME 'selection'
     EXPRESSION "%id%"
       STYLE
         SYMBOL 0
         SIZE 6
       WIDTH 3
         OUTLINECOLOR 255 0 0
         ANTIALIAS TRUE
         COLOR 255 0 0
       END
    END
 END

And now call this layer with a WMS GetMap request where you add 
"&id=123" to the end of the request string.





More information about the MapServer-users mailing list