# Cesium.WebMapServiceImageryProvider and enablePickFeatures to extract \<values\> from xml?

**URL:** <https://community.cesium.com/t/cesium-webmapserviceimageryprovider-and-enablepickfeatures-to-extract-values-from-xml/37880>\
**Category:** CesiumJS\
**Created:** [January 11, 2025, 10:23pm UTC](https://community.cesium.com/t/cesium-webmapserviceimageryprovider-and-enablepickfeatures-to-extract-values-from-xml/37880 "2025-01-11T22:23:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marine-ecologist](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marine-ecologist/32/27592_2.png) [@marine-ecologist](https://community.cesium.com/u/marine-ecologist)\
**Post date:** [January 11, 2025, 10:23pm UTC](https://community.cesium.com/t/cesium-webmapserviceimageryprovider-and-enablepickfeatures-to-extract-values-from-xml/37880/1 "2025-01-11T22:23:43Z")

</div>

I’m using cesium to add a wms layer to the globe and then extracting the lon, lat, and corresponding value for a pixel when clicked. So far this works fine using:

```auto
const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);

handler.setInputAction(async (click) => {
  const cartesian = viewer.camera.pickEllipsoid(click.position, scene.globe.ellipsoid);
   
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);`

```

Example code [here](https://sandcastle.cesium.com/#c=dVPBjtowEP2VESeQqK0eemEBdUWpisqqVbMql0jsYA/EwrEt2wmiq/33OgkpdLs9ReN5783MmwnnsDIqKtTqF0EsCBYUVFVCrehEPjfCmhAvEczA0OmCYD/bt2E+EG28sCaiMokzGMNzbl5Gd7np+UGQoUTvdFgbtmnO4V5KyLJH2DxkoPF8LRpCXDfxladKPJA/t6+BoZSr7uG7t7WSTTMGblvc0O4BXUa+VoJeY58bMEDl9QSeihhdmHDukN45LJA5FMrawAo8oVKMZMVj4UnKwE9l4LI4bT8cy6dxJ9L2HSaQDxY/Nts0TTKhyzj0WFJss5eKANGjCSlDJk5SUNG4z+ytLzE2Qu2s3JnDH6mX9vsyys2o9+4T7ZPl7d4KNFIns5ICCK3EEahO+qF3s8//tcNMeCKTpWFp2aC/dKDh7Z6YQFNj6GpeVFiguDKuivciKmuGGM5GwLCtO4LZvBu1KyzQx1QNzXWPIlnik8cJvdRauWCV7MjM2aAayXF3M+yg7Y4Y9aimi2RFOq/x/2Z4PDti6+Xnx+1ivVp8Hd0NxoNpiGdN897lj6p01sdm90PGeKTSaUxN8l0ljhSZCOFSCKb8ljqVqgYlZ28cfTIdQ0iZfaV1lv6mfDCf8oT/h6otSmUO32ry6W4aWPF+vu4eGWNTnsK3mdFavUP/Svk3)

 ![Screenshot 2025-01-12 at 7.52.13 am](https://global.discourse-cdn.com/cesium/original/3X/1/e/1e5abb5abd19ef4a1632efbf96d0e2c563a4faae.jpeg)

As far as I understand, `viewer.camera.pickEllipsoid` returns the point on the surface of the ellipsoid or map in world coordinates, which returns the corresponding `<FeatureInfoResponse>` from the WMS xml:

```auto
<?xml version="1.0" encoding="UTF-8"?><FeatureInfoResponse>
    <longitude>-92.724609375</longitude>
    <latitude>1.142578125</latitude>
    <iIndex>1745</iIndex>
        <jIndex>1777</jIndex>
        <gridCentreLon>-92.72500314459501</gridCentreLon>
        <gridCentreLat>1.124999980921217</gridCentreLat>
    <FeatureInfo>
        <time>2025-01-09T12:00:00.000Z</time>
        <value>26.59</value>
            </FeatureInfo>
    </FeatureInfoResponse>

```

Question: how can I dynamically capture the `<time>` and `<value>` from the `<FeatureInfo>` in the `cesium-infoBox-description` as `const time` and `const value`? on click?

---

<div class="post-metadata">

**Author:** ![jjspace](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/jjspace/32/4102_2.png) [@jjspace](https://community.cesium.com/u/jjspace)\
**Post date:** [January 13, 2025, 9:50pm UTC](https://community.cesium.com/t/cesium-webmapserviceimageryprovider-and-enablepickfeatures-to-extract-values-from-xml/37880/2 "2025-01-13T21:50:58Z")

</div>

Hi @marine-ecologist, thanks for the question.

In order to extract information from the imagery layer you need to pick it directly. The info shown in the top right is just an entity selection helper from the `Viewer`. The way we extract the info you actually want is through the [`ImageryLayerCollection.pickImageryLayerFeatures`](https://cesium.com/learn/cesiumjs/ref-doc/ImageryLayerCollection.html#pickImageryLayerFeatures). This takes a `ray` which can be found using [`Camera.getPickRay`](https://cesium.com/learn/cesiumjs/ref-doc/Camera.html?classFilter=camer#getPickRay)

```js
const pickRay = scene.camera.getPickRay(click.position);
const imageryLayerFeatures = await scene.imageryLayers.pickImageryLayerFeatures(pickRay, scene);
console.log(imageryLayerFeatures[0]);
console.log(imageryLayerFeatures[0].description);

```

The returned objects are [ImageryLayerFeatureInfo](https://cesium.com/learn/cesiumjs/ref-doc/ImageryLayerFeatureInfo.html) objects. From there you can do whatever you want with the data. I slightly modified your sandcastle to show off using that above code, check that [here](https://sandcastle.cesium.com/#c=jVRdb9owFP0rFk8gMXt72AulaBVrNTSqVU21PixTe7FviVXHtmwniFX89zpxUhhl0p6i+3HOuT6+DmNkoWWQoOQfJKFAMkcvq5LUEjfocs2N9qGLyDnRuOk66M82N8wHvI3nRgeQOmIGY/KS693oLNc93nPUGOGJh7ZhW2aMXAhBsuyO3F9nRMF2L+p9WDbxHidLWKPbtllPQYhFStw4U0vRDKPJ4Yj3uLoGm6GrJcfj3pemmZDKqQl5LEKwfsKYBfxgoQBqgUtjPC1gA1JSFBULhUMhPNuUnoli8/D5uXwcJ5J2bj8h+WB+e/8QTxNNSBULDkoMbbVTJCQ40D5WUIdJDCoc95Un40oIDVF7Vmb1+o1q1353o1yPeu++4lO0vL23ArRQ0azIQLiS/JlgHfl972Zf/+sOM+4QdRYPi5dN97fUNDy8J8pB1+CTZsdCPYaFtlW44EEaPQS/1ZwMW90ROZ+loyZhDi5ENdD7e+TREhc9jt2XSknrjRQJTK3xsqEcp52ha2VWSLHvaqboiRs4iqOtakmPuPYgo5Aqsx6+zfS+lFgPl7fJ3MI2CvV+tNOvMdykygm5hDzc1yuEUDn0kaZZqe5NHK10I7U4ARp2M3Su9Ar9zKd0fn38/Z9tVKDnTtp+9t34X+txt7VIl5dXdw/z5WL+fXQ2GA+mPmwVzvoF/iJLa1xontWQUhawtAqi12xVRV8D5d4nzwmZskPoVMiaSHF+4n8S9xm8j5WnSqks/qjywWzKYv87qDIgpF7/qNHFJ9m0FZ9my5SklE5ZDE8jgzFqBe6I+RU)

(Since CesiumJS is open source, feel free to look at the implementation in `Viewer` [here](https://github.com/CesiumGS/cesium/blob/9fa039dd402d42a6589b45fb9ef3f720f7b0e845/packages/widgets/Source/Viewer/Viewer.js#L152))

Hopefully that helps but let me know if that doesn’t work for you.
