I am trrying to call WMS layer from Geoserver using Arcgis API for JS

262
0
02-05-2021 01:23 AM
ratneshsharma
New Contributor

 

HI

I am trying to call WMSlayer from Geoserver using Arcgis API for JS

But the layer not opening in web browser

Please rectify the code and share

thanks with regards

Ratnesh Sharma

CODE_SAMPLE

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>WMSLayer | Sample | ArcGIS API for JavaScript 4.16</title>

<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>

<link rel="stylesheet" href="/arcgis_js_api/library/4.14/esri/css/main.css">
<script src="/arcgis_js_api/library/4.14/init.js"></script>


<script>
require(["esri/Map",
"esri/views/SceneView", "esri/widgets/LayerList", "esri/layers/WMSLayer"],
function (Map, SceneView, LayerList, WMSLayer)
{
var layer = new WMSLayer({
url: "http://localhost:8181/geoserver/sf/wms",
sublayers: [
{
name: "roads"
}
]
});

var map = new Map({
basemap: {
baseLayers: [layer]
}
});

var view = new SceneView({
container: "viewDiv",
map: map
});
view.when(function() {
var layerList = new LayerList({
view: view
});
// Add widget to the top right corner of the view
view.ui.add(layerList, "top-right");
});
});
</script>
</head>
<body class="calcite">
<div id="viewDiv"></div>
</body>
</html>

Tags (2)
0 Kudos
0 Replies