Hey- Gregor Mosheh wrote: > A request has come up to highlight one or more polygon features, e.g. > search results or the like. What would be an advisable way of doing this? > > Using plain Mapserver, we used additional query args and a filter, to > create a layer which would only show only those features in some ungodly > highlight-worthy color. The WMS server is still Mapserver, and I'd not > be averse to using a OL.Mapserver layer. > > Alternately, I imagine that one could fetch the feature with WFS and > draw it in some ungodly highlight-worthy color. > > And if there's a wiki page or example that I missed, even better! >
Depends what you mean by a feature. If you're rendering vector features on the client side, the SelectFeature control is all about clicking on or hovering over a feature to select it (add it to the layer's selectedFeatures array and draw it with a select style). If this fits your case, see: http://openlayers.org/dev/examples/select-feature.html You can also use the SelectFeature control to select a feature programmatically. That is control.select(feature); control.unselect(feature); If you are rendering your features server side (and you want to keep doing this), then you can "select" with SLD via WMS. This of course presumes that you know enough about what feature you want to select to create a filter. Of course, GetFeatureInfo provides a nice way to get feature attributes based on pixel location (see http://openlayers.org/dev/examples/getfeatureinfo.html). Two requests just to highlight a selected feature is a bit clunky (one to get feature info, one to apply SLD to a GetMap request). And who likes creating all that sld/filter stuff anyway? Easier just to get your feature client side and style it however you like. For docs on the SelectFeature control, see http://dev.openlayers.org/apidocs/files/OpenLayers/Control/SelectFeature-js.html Tim _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users