标题非常自我解释。我试图在ESRI的arcgis javascript库中显示WMS图层。我从v3.2转到v4.7,我对WMSLayer有些困难。
我有这段代码在ArcGIS Javascript v3.2中显示一个图层
<script>
var map;
require(["esri/map", "esri/layers/WMSLayer", "esri/config", "dojo/domReady!"],
function(Map, WMSLayer, esriConfig) {
esriConfig.defaults.io.proxyUrl = "/proxy/";
esriConfig.defaults.io.corsEnabledServers.push("fsapps.nwcg.gov");
map = new Map("map", {
basemap: "streets",
center: [-98, 37],
zoom: 5
});
var wmsLayer = new WMSLayer("https://fsapps.nwcg.gov/afm/cgi-bin/mapserv.exe?map=conus.map&", {
format: "png",
visibleLayers: ['Last 24 hour fire detections']
});
map.addLayer(wmsLayer);
});
</script>
这很有效,但是当我在v4.7中尝试这个时,我什么都没得到。
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/WMSLayer",
"esri/widgets/Legend",
"esri/config",
"dojo/domReady!"
], function(Map, MapView,WMSLayer,Legend,esriConfig) {
esriConfig.request.corsEnabledServers.push("fsapps.nwcg.gov");
var layer = new WMSLayer({
url: "https://fsapps.nwcg.gov/afm/cgi-bin/mapserv.exe?map=conus.map&",
imageFormat:'image/png',
sublayers: [
{
name:"Last 24 hour fire detections"
}
]
});
var map = new Map({
basemap: 'streets',
});
map.add(layer);
var view = new MapView({
container: "viewDiv",
map: map,
center: [-98, 37],
zoom: 5
});
});
我做错了什么