Select to view content in your preferred language

error "Accessor#set Assigning an instance of 'esri.layers.MapImageLayer' which is not a subclass of 'esri.Basemap'" while creating map from mapserver

675
0
05-04-2023 10:25 PM
bogind
by
Occasional Contributor

Using version 4.26 through npm as an ESM module.
I came across this error and another somewhat unrelated question with a similar syntax helped me find my bug

Accessor#set Assigning an instance of 'esri.layers.MapImageLayer' which is not a subclass of 'esri.Basemap'

The code I tried to use was:

 

this.imageryLayer= new MapImageLayer({
      url:"URL to a MapServer"
    })

this.map = new Map({
      ground: "world-elevation",
      basemap: this.imageryLayer,
    })

 

 

The reason it failed, was because I didn't cast the MapImageLayer to a BaseMap.
This piece of code solved it:

 

this.imageryLayer= new MapImageLayer({
      url:"URL to a MapServer"
    })

this.ImageryBaseMap = new Basemap({
      baseLayers:[this.imageryLayer],
      title: 'Imagery',
      id:'imagery'
    })

this.map = new Map({
      ground: "world-elevation",
      basemap: this.ImageryBaseMap ,
    })

 

 
This isn't really a question, just added this here for anyone else who might look this up.

0 Replies