[GIS] How to run an Identify task on a WMS layer

arcgis-javascript-apiwms

I'm new to WMS layers, and am looking for a way to retrieve a layer's attributes when clicking on the map, using the ArcGIS Server JS API.

The documentation is a bit sparse, but from this question it appears that I'll need to construct a query using GetFeatureInfo.

Before I re-invent the wheel, has anyone written a wrapper function or sample code which builds the appropriate query when the user clicks on the map?

Best Answer

The WMS GetFeatureInfo request is very similar to the GetMap request. There is an example here showing code sample for GetFeatureInfo.

Also, keep in mind, that the GetFeatureInfo is not "standardized", so depending on server vendor, the response is differently formatted. Expect to do some extra parsing/styling.