Select to view content in your preferred language

Cannot read property 'on' of null at Object.set (ExportWMSImageParameters.js:5)

3189
3
08-04-2017 06:26 AM
selcukcelik
New Contributor

Hi,

possilel bug issues about WMSLayer (api:4.4)

I am getting error while trying to use WMSLayer. 

ERROR: Cannot read property 'on' of null     at Object.set (ExportWMSImageParameters.js:5)

sample code from Sandbox: layers-wms

esriConfig.request.corsEnabledServers.push(
"mesonet.agron.iastate.edu");

layer = new WMSLayer({
// See http://mesonet.agron.iastate.edu/ogc/ for more WMS services from Iowa Environmental Mesonet (Iowa State University)
url: "https://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi"
});

map = new Map({
//basemap: "dark-gray",
layers: [layer]
});
view = new MapView({
container: "viewDiv",
//center: [-123, 49],
//zoom: 5,
map: map
});

My code is smilar but it is typescript:

1- I am using for CORS:

esriConfig.request.corsEnabledServers.push(
"mesonet.agron.iastate.edu");

or:

urlUtils.addProxyRule({
urlPrefix: "https://mesonet.agron.iastate.edu",
proxyUrl: "/proxy"

});

and rest of the code:
var wmsLayer: any = new WMSLayer();
wmsLayer.url = "https://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi"

this.mapManagerService.map.add(wmsLayer);

by the way I cant reach WMSLayer "url" property so I define it "any" type (Arcgis js Api: 4.4)

Thanks.

0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor

Looks like a bug in the typings that will be fixed at the next release.  To workaround the issue for now you can update the index.d.ts file to add url to the WMSLayerProperties.

  interface WMSLayerProperties extends LayerProperties, PortalLayerProperties {
    copyright?: string;
    customLayerParameters?: any;
    customParameters?: any;
    description?: string;
    featureInfoFormat?: string;
    featureInfoUrl?: string;
    fullExtents?: ExtentProperties[];
    imageFormat?: string;
    imageMaxHeight?: number;
    imageMaxWidth?: number;
    imageTransparency?: boolean;
    spatialReference?: SpatialReferenceProperties;
    spatialReferences?: number[];
    sublayers?: Collection | any[];
    version?: string;
    url?: string;
  }
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I added a TypeScript WMSLayer sample here that updates the WMSLayerProperties interface in app/updates.d.ts. 

TSSamples_JSAPI/WMSLayer at master · kellyhutchins/TSSamples_JSAPI · GitHub 

0 Kudos
baskentedas
New Contributor II

still a bug in 4.5?

thanks.

0 Kudos
KellyHutchins
Esri Frequent Contributor

The issue is resolved in 4.5. I just tested with the sample and it works just fine without the uopdates.d.ts file included. 

0 Kudos