I have a web map application which displays WMS layers from GeoServer. I am looking to add a functionality which will allow users to click on multiple map objects. The application will then generate a bar chart based on the data of the selected objects and presented it to the user. Any hints or guidance on how to achieve this would be greatly appreciated.
1 Answer
I'm not sure about what you mean the "map objects" and how you serve the "data of objects" in the question. Are they vector features on a vector layer that you added to map, or just the objects come with the wms layer.
If they are vector features, you can easily get the feature information (data) via OpenLayers API. If the objects are inside the wms layer, then probably you can have a look at this example, get feature's information via Openlayers WMSGetFeatureInfo
control. Please note there are some prerequisites for this control to work.
After you get the data, store them and organize them in a readable way by the chart library you use.
If you are looking for some javascript chart library, here is a stackoverflow question that can be a good start point.
-
Thanks for your help Mingfeng. The map objects are objects that come with the wms layer. I already have WMSGetFeatureInfo set up here and it returns info with a format of html/text. Looking for some simple way to grap the attribute values from the html.– K HsuehCommented Jul 8, 2013 at 10:50
-
The 'getfeatureinfo' event object also contains a 'features' property. Can you get attribute values from the 'features' property? I think it's much easier to get attribute values from javascript objects than to process html texts.– mfdevCommented Jul 8, 2013 at 11:57
-
The features property is not working properly - I wonder if it is because I have used templates (content.ftl) in the geoserver data directory. When I try to print our the event.features.length, it always returns a value of 0.– K HsuehCommented Jul 10, 2013 at 0:25