How to display WMS layers using ArcGIS Javascript API in MapView?

08-16-2022 07:10 AM
Occasional Contributor

i am trying to display a WMS layer which is coming from a server. The WMS has multiple sublayers. I am using the sandbox for developing and testing the code for now. I am able to access the WMS on the SceneView but i cannot access it over the mapview. How can i configure my code to be able to view the map in 2D or in map view? 



0 Kudos
3 Replies
Frequent Contributor II

That sample sets the SpatialReference of the View, so when switching to the MapView, don't set the SpatialReference and let the view adopt the SR of the layer if it's the basemap layer.

0 Kudos
Occasional Contributor

@ReneRubalcava  I dont want it to be the basemap layer. I want to add it over a basemap

0 Kudos
Esri Regular Contributor

This WMS service has WGS84 projection so it can only be displayed over basemaps that are in WGS84 or the MapView.spatialReference needs to be in wgs84. 

const layer = new WMSLayer({
  url: "",
  sublayers: [{
    name: "OSM-WMS"

const map = new Map({
  basemap: new Basemap({
    portalItem: {
      id: "02b1f120c3674bfe896ac81731be1739"
  layers: [layer]

const view = new MapView({
  container: "viewDiv",
  map: map

Here are ArcGIS online basemaps that are in WGS84: