WMSLayerInfo 未定义 - arcgis 4.13 [英] WMSLayerInfo is not defined - arcgis 4.13

查看:25
本文介绍了WMSLayerInfo 未定义 - arcgis 4.13的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,今天刚开始使用 arcgis 并尝试从 geoserver 添加 wms 层.我使用的是 javascript api v 4.13.

Folks, just started using arcgis today and attempting to add a wms layer from geoserver. I am using the javascript api v 4.13.

我从这个例子开始:

https://developers.arcgis.com/javascript/latest/sample-code/layers-wms/live/index.html

然后继续添加 WMS 层如下(我添加了部分//TEST - START 到 END):

Then proceeded to add the WMS layer as follows (I added the section // TEST - START to END):

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>WMSLayer - 4.13</title>

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

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.13/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.13/"></script>

    <script>
      require([
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/WMSLayer",
        "esri/layers/WMSLayerInfo",
        "esri/geometry/Extent"
      ], function(Map, SceneView, WMSLayer, WMSLayerInfo, Extent) {
        var layer = new WMSLayer({
          url: "https://ows.terrestris.de/osm/service",
          sublayers: [
            {
              name: "OSM-WMS"
            }
          ]
        });

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

        var view = new SceneView({
          container: "viewDiv",
          map: map
        });

        // TEST - START
    var layer1 = new WMSLayerInfo({
        name: 'sf:test1',
        title: 'sf:test1'
    });

    var resourceInfo = {
        extent: new Extent(3, 4, 5, 6, {
        wkid: 2236
    }),
        layerInfos: [layer1]
    };

    var wmsLayer = new WMSLayer('https://myserver/geoserver/sf/wms', {
        resourceInfo: resourceInfo,
        visibleLayers: ['sf:test1']
    });

    map.addLayers([wmsLayer]);

    // TEST - END



      });
      /***********************************
       * Data attribution:
       *  OpenStreetMap WMS by terrestris GmbH and Co. KG. Following sources were used:
       *  (c) OpenStreetMap contributors (http://www.openstreetmap.org/copyright)
       *  (c) OpenStreetMap Data (http://openstreetmapdata.com)
       *  (c) Natural Earth Data (http://www.naturalearthdata.com)
       *  (c) ASTER GDEM 30m (https://asterweb.jpl.nasa.gov/gdem.asp)
       *  (c) SRTM 450m by ViewfinderPanoramas (http://viewfinderpanoramas.org/)
       *  (c) Great Lakes Bathymetry by NGDC (http://www.ngdc.noaa.gov/mgg/greatlakes/)
       *  (c) SRTM 30m by NASA EOSDIS Land Processes Distributed Active Archive Center (LP DAAC, https://lpdaac.usgs.gov/)
       *********************************/
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
  </body>
</html>

我收到错误WMSLayerInfo 未定义".我知道它可能是非常基本的东西,但我无法在网上找到答案.先谢谢你.

I am receiving the error "WMSLayerInfo is not defined". I know its probably something very basic but I cannot find the answer online. Thank you before hand.

推荐答案

在您的 require 语句中,您正在尝试加载 "esri/layers/WMSLayerInfo" 模块 Arcgis Javascript API v4.x

In your require statement, you are trying to load "esri/layers/WMSLayerInfo" module which does not exists in Arcgis Javascript API v4.x

只需将其从您尝试加载的模块列表中删除即可.

Just remove it from the list of modules you are trying to load.

require([
        "esri/Map",
        "esri/views/SceneView",
        "esri/layers/WMSLayer",
        "esri/geometry/Extent"
      ], function(Map, SceneView, WMSLayer, Extent) {

})

不要忘记删除代码中对 WMSLayerInfo 的任何引用,并确保使用 ArcGIS Javascript API v4.x 文档.

Dont forget to remove any references to WMSLayerInfo in your code and be sure to use the ArcGIS Javascript API v4.x documentation.

这篇关于WMSLayerInfo 未定义 - arcgis 4.13的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆