I am trying to load a geoserver wms layer to a WMSLayer using Esri JS API 4.x, thought the code below loads ok using Esri JS API 3.x
require(["esri/layers/WMSLayer","esri/layers/WMSLayerInfo"],function(WMSLayer,WMSLayerInfo){
var wmsinfo = new WMSLayerInfo();
var resourceInfo = {
extent: Map.extent,
layerInfos: [wmsinfo],
spatialReference: {
wkid: 4326
}
};
var name = "HTM:name_of_layer_on_geoserver.tif";
var url = "www.geoserver.local:8080/geoserver/HTM/wms?";
layer = new WMSLayer(url, {
id: "tempid",
spatialReference: new SpatialReference({ wkid: 3857 }),
resourceInfo: resourceInfo,
visibleLayers: name,
customLayerParameters: {CRS: 'EPSG:3857'}
});
Map.addLayer(layer);
});
now im trying to convert it.
require(["esri/layers/WMSLayer"],function(WMSLayer){
//var wmsinfo = new WMSLayerInfo(); //<-this is deprecated, what would be the equivalent.
var resourceInfo = {
extent: View.extent,
layerInfos: [],
spatialReference: {
wkid: 4326
}
};
var name = "HTM:name_of_layer_on_geoserver.tif";
var url = "www.geoserver.local:8080/geoserver/HTM/wms?";
//moved url to properties, instead of inline argument
layer = new WMSLayer({
id: "tempid",
url:url,
spatialReference: new SpatialReference({ wkid: 3857 }),
resourceInfo: resourceInfo, //this doesnt seem to be available
visibleLayers: name,
customLayerParameters: {CRS: 'EPSG:3857'}
});
layer.load().then(()=>{
Map.addLayer(layer);
});
});
i tried replacing visiblelayer property with sublayer but doesnt seem to work.
if i just add it to Map without the load(), it will be white screen, if i do call load(), it will stuck in getcapabilities request. i where lost that a specific class doesnt have equivalent or samples that will load a single layer rather than the all layers available in the server.
what am i missing?
Angelo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.