# Errors when imageryProviderViewModels is defined

**URL:** <https://community.cesium.com/t/errors-when-imageryproviderviewmodels-is-defined/25826>\
**Category:** CesiumJS\
**Created:** [August 2, 2023, 11:14pm UTC](https://community.cesium.com/t/errors-when-imageryproviderviewmodels-is-defined/25826 "2023-08-02T23:14:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sakna.hewagalamulage](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sakna.hewagalamulage/32/3476_2.png) [@sakna.hewagalamulage](https://community.cesium.com/u/sakna.hewagalamulage)\
**Post date:** [August 2, 2023, 11:14pm UTC](https://community.cesium.com/t/errors-when-imageryproviderviewmodels-is-defined/25826/1 "2023-08-02T23:14:21Z")

</div>

Hi  
I am defining the imageryProviderViewModels, when instantiating the viewer. However, I am getting the following error:

 ![image](https://global.discourse-cdn.com/cesium/original/2X/6/61664f92678c84fff7aa4ace77ba9d56d65e9890.png)

I have provided a link to the Sandcastle code.

> **[Cesium Sandcastle](https://sandcastle.cesium.com/#c=xVRNb9pAEP0rKy4YCdlq0hMhqIWkElJoq6Amh9LDej3AtOtddz9IKeK/d4wxtgOV0gOpL2vvvJk3+96shVbWMUz5Asz6AeFpohOQll2zr9+uZorRcxQMM2+XQRFkTMETG4FFn4afjV5hAuYADTYlinA8hR5rD1Et2HswyGW7W0VRaPXFyF5ZKvYoE6rhJdB2UAEZaz9isgBno3He2H4x65LcRjFRFAxhphbtKrdTI3RaS4dZs6Ow3pIwwB1q9cErka89Nt+/saDDNvWWDDhvVF2KsVbP+go2jFsLbpz02AXbdq6qAtsD67ZTvOXRs6k/4ZndH5g9oVuyOx5T4fPbUfC83JS/NPpaLl3+f5fuNU/O6Ute/18NyXNey4K3L7NA7P5iK5IUDP26auUfdnvBrCV23yOtHEcFZtbqNjuzAhTkhhy0nZY74XR0+/H28qZbx2Oz6cr53vEwNBIdpiCpBVKJSwuN2NxLaUlOUEPv3E7JIwxXVH8v81FwAVoQpTkVo7oJuhu0meTrU4CUZ3Sc77A3sabiI8QTMII7bSpE0Ok2rf3pwbp7UMRfCOmMbzKgmuuh/nWS3HI+5WkmgRS8qIV2A9DqtvrWrSUMysA7TDNtHPM09mEYOaBU7mjOYy9+gAuFteXk9KN6aj/BFcPk+sRIMCFp8iiS+zDF3zBrDfoR4Y9SJd0BuhCfVmBIzBy2fDO4KzbDMOxH9Hk6M79RMTfPKv8B)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

Any help is highly appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![anneg](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/anneg/32/11217_2.png) [@anneg](https://community.cesium.com/u/anneg)\
**Post date:** [August 4, 2023, 12:26pm UTC](https://community.cesium.com/t/errors-when-imageryproviderviewmodels-is-defined/25826/2 "2023-08-04T12:26:00Z")

</div>

You need to use `fromAssetId` instead of using the constructor.

See [IonImageryProvider - Cesium Documentation](https://cesium.com/learn/cesiumjs/ref-doc/IonImageryProvider.html)

This has recently changed (version 1.107 i think).

So in your sandcastle, use:  
`return Cesium.IonImageryProvider.fromAssetId(3);`  
instead of  
`return new Cesium.IonImageryProvider({ assetId: 3 });`

---

<div class="post-metadata">

**Author:** ![sakna.hewagalamulage](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sakna.hewagalamulage/32/3476_2.png) [@sakna.hewagalamulage](https://community.cesium.com/u/sakna.hewagalamulage)\
**Post date:** [August 8, 2023, 12:42am UTC](https://community.cesium.com/t/errors-when-imageryproviderviewmodels-is-defined/25826/3 "2023-08-08T00:42:52Z")

</div>

Thanks for this
