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.

  • Do you also want to show the bar chart somewhere on the map? – mfdev Jul 8 '13 at 6:59
  • No, preferably I would like to show it somewhere outside the map. – K Hsueh Jul 8 '13 at 8:17

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 Hsueh Jul 8 '13 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. – mfdev Jul 8 '13 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 Hsueh Jul 10 '13 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.