highlight

John Fletcher jfletcher at LATITUDEGEO.COM
Wed Jan 26 11:00:41 PST 2005


> Is it possible to send commands to MapServer to highlight 
> some shapes in a shapefile dynamically?

You can send an SLD to MapServer when you want to highlight some
features.  Roughly, the SLD will have 2 styling rules - one for the
highlighting and another one for the default style.  It will look
something like the following for a point layer:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0">
    <NamedLayer>
        <Name>LAYER_NAME</Name>
        <UserStyle>
            <FeatureTypeStyle>
                <Rule>
                    <Filter>
                        <PropertyIsEqualTo>
                            <PropertyName>ATTR</PropertyName>
                            <Literal>VAL</Literal>
                        </PropertyIsEqualTo>
                    </Filter>
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>circle</WellKnownName>
                                <Fill>
                                    <CssParameter
name="fill">#00FFFF</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>6.0</Size>
                        </Graphic>
                    </PointSymbolizer>
                </Rule>
                <Rule>
                    <Filter>
                        <Not>
                            <PropertyIsEqualTo>
                                <PropertyName>ATTR</PropertyName>
                                <Literal>VAL</Literal>
                            </PropertyIsEqualTo>
                        </Not>
                    </Filter>                    
                    <PointSymbolizer>
                        <Graphic>
                            <Mark>
                                <WellKnownName>circle</WellKnownName>
                                <Fill>
                                    <CssParameter
name="fill">#0000FF</CssParameter>
                                </Fill>
                            </Mark>
                            <Size>6.0</Size>
                        </Graphic>
                    </PointSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

This is based on a point layer drawn with 6 pixel wide circles.  It will
highlight features that have ATTR=VAL in yellow, while drawing the rest
of the features in blue.  You'll probably want to make sure the 'other'
rule (in the case above, the one inside the Not element) has rendering
consistent with the default rendering in the mapfile.  If you have a
large number of classes defined in your mapfile, this method can get
extremely cumbersome, but it's the best way I can come up with at the
moment.  Would be nice to not have to specify the rendering for the
non-highlighted features, and have MapServer just fall back to the
rendering defined in the mapfile, but that can't be done at the moment.

There's more information on sending SLDs to MapServer at the SLD How-To
(http://mapserver.gis.umn.edu/doc44/sld-howto.html).

John



More information about the MapServer-users mailing list