Proper Way to Load WMSLayer in ArcGIS JSAPI 4.12?

12-12-2019 12:04 AM
New Contributor III

I'm getting '#load() Failed to load layer TypeError: Cannot read property 'indexOf' of undefined' error when I tried to load WMSLayer in my application.

I've tried several different WMS service URLs but with no positive results. The code from the official sample doesn't work either.

similar question has been asked and someone suggested that using proxy might solve the issue, but implementing proxy seems to be a quite complicated process. Please note that the URL in the question has http instead of https like in my application, the error is different from what I'm getting as well.

Does anyone figure out what I'm doing wrong or anything I missed out?

Here's my code :

let wmsLayer = new WMSLayer({    title: "WMS Layer",    url: "",    sublayers: [{        name: "OSM-WMS"    }]});var basemap = new Basemap({    baseLayers: [wmsLayer]});var map = new Map({    basemap: basemap,    layers: [gridLayer, forceSymbolLayer, measurementLayer, sketchLayer]});var mapView = new MapView({    map: map,    zoom: initZoom,    center: initPosition});
0 Kudos
1 Reply
Esri Contributor

Hi Jerry,

I created a codepen from the code you provided above, but removed the other layers (because I did not have their information):  The WMSLayer seems to load fine in this sample. Is the error coming from one of your other layers?



0 Kudos