Web Map Service (WMS) Vs Web Map Feature (WFS)
OpenScales Flex API handles both WMS and WFS. Its one of the really nice things about the API. The difference confused me when I first came across these terms years ago. Simply; WMS is a REST based request which returns a image. In contrast WFS returns feature attributes. Allowing the client (Flex) to build feature objects based on feature geometry. More client intensive, but WFS allows feature interactivity. Thus click on a polygon feature (WFS object) causes it to be highlighted and the feature attributes displayed. With WMS, this same functionality would require an additional server call, and image generation (more about request/response and WFS in another blog entry).
So lets talk styling. Let’s suppose we are using Geoserver for our WMS and WFS geospatial requests. Geoserver allows for easy custom styling of WMS layers, producing more attractive, intuitive maps. Now OpenScales styles the WFS features, but is limited. So we have in one case beautifully styled layers, and in the other feature interactivity. Suppose we want both?
Certainly there are ways to use one or other of WMS or WFS alone to provide styling and interactivity. But from my experience the results were less than optimum. How about using both services; so render a layer using both WMS the WFS? Two problem; first, both layers will appear in the TOC, or layer list. Second, the styling of the WFS layer will still obscure some of the WMS styling. We can get round the first problem by simply checking, in the code, the layers being added to the layer list, and avoid layer duplication. In my case I only display the WMS layer in the TOC.
The second problem is more challenging. We could set the WFS layer to a 0 transparency. But then if a user selects a feature, the yellow highlighting will also be at a 0 transparency, and thus not visible. After mulling over this for a while, I came up with a solution. In Flex add an additional empty layer on top of the map, and set its transparency to 1. Set the WFS layer to a transparency of 0. When a user clicks on a feature in the WFS layer, copy this feature to the top layer. Voila, the feature is highlighted yellow, plus we maintain the beautiful WMS styling.
This may be overkill for many applications. But the combination of WMS and WFS for a single feature layer provides the strength of both; custom styling with feature interactivity.
Related Resources
Recent Comments