主题不能得到一个层出现在地图上的ArcGIS JavaScript地图SDK问题 //www.gamepadva.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-a-layer-to-appear-on-map/m-p/1246219#M79804

这是我第一次使用JavaScript的ArcGIS API。我遇到了一个相当简单的错误。我不能得到我在ArcGIS Online上托管的图层出现在地图上。这是我的代码:< / P > < DIV > < DIV > < SPAN >要求< / SPAN > < SPAN > ([< / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN >“esri / config”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN >“esri /地图”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN > " esri /层/ FeatureLayer”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,   "esri/views/MapView"

], function (esriConfig, Map, MapView, FeatureLayer) {

    //Setting the API key
    esriConfig.apiKey = api key hidden

    const map = new Map({
        basemap: "arcgis-topographic"
    });

    const view = new MapView({
        container: "viewDiv",
        map: map,
        extent: {
            xmin: -88.4407865369763,
            ymin: 44.2519512604157,
            xmax: -87.57033074655209,
            ymax: 44.58559644055305,
            spatialReference: 4326
        },
    });

    let one_year_high = new FeatureLayer({
        url: "https://services.arcgis.com/HRPe58bUyBqyyiCt/ArcGIS/rest/services/1_year_high_lake_level/FeatureServer/13",
        id: "1-year-high",
        apiKey: api key hidden
    });

    map.add(one_year_high);

});

 

This script produces the following error in my browser:

[esri.Map] #add() The item being added is not a Layer or a Promise that resolves to a Layer.

My layer can be found here: https://services.arcgis.com/HRPe58bUyBqyyiCt/ArcGIS/rest/services/1_year_high_lake_level/FeatureServer/13

I can't figure out why it won't appear.

 

Thanks in advance.

 

2023年1月6日星期五22:38:34 GMT JACOBSTEINBERG 2023 - 01 - 06 - t22:38:34z 无法让图层出现在地图上 //www.gamepadva.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-a-layer-to-appear-on-map/m-p/1246219#M79804

这是我第一次使用JavaScript的ArcGIS API。我遇到了一个相当简单的错误。我不能得到我在ArcGIS Online上托管的图层出现在地图上。这是我的代码:< / P > < DIV > < DIV > < SPAN >要求< / SPAN > < SPAN > ([< / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN >“esri / config”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN >“esri /地图”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,,< / SPAN > < SPAN > " esri /层/ FeatureLayer”< / SPAN > < SPAN >, < / SPAN > < / DIV > < DIV > < SPAN >,   "esri/views/MapView"

], function (esriConfig, Map, MapView, FeatureLayer) {

    //Setting the API key
    esriConfig.apiKey = api key hidden

    const map = new Map({
        basemap: "arcgis-topographic"
    });

    const view = new MapView({
        container: "viewDiv",
        map: map,
        extent: {
            xmin: -88.4407865369763,
            ymin: 44.2519512604157,
            xmax: -87.57033074655209,
            ymax: 44.58559644055305,
            spatialReference: 4326
        },
    });

    let one_year_high = new FeatureLayer({
        url: "https://services.arcgis.com/HRPe58bUyBqyyiCt/ArcGIS/rest/services/1_year_high_lake_level/FeatureServer/13",
        id: "1-year-high",
        apiKey: api key hidden
    });

    map.add(one_year_high);

});

 

This script produces the following error in my browser:

[esri.Map] #add() The item being added is not a Layer or a Promise that resolves to a Layer.

My layer can be found here: https://services.arcgis.com/HRPe58bUyBqyyiCt/ArcGIS/rest/services/1_year_high_lake_level/FeatureServer/13

I can't figure out why it won't appear.

 

Thanks in advance.

 

2023年1月6日星期五22:38:34 GMT //www.gamepadva.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-a-layer-to-appear-on-map/m-p/1246219#M79804 JACOBSTEINBERG 2023 - 01 - 06 - t22:38:34z
不能让图层出现在地图上 //www.gamepadva.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-a-layer-to-appear-on-map/m-p/1246285#M79811

在你的require和function中,MapView和FeatureLayer顺序被交换了。当使用amd时,顺序很重要。

2023年1月7日星期六19:13:15 GMT //www.gamepadva.com/t5/arcgis-javascript-maps-sdk-questions/cannot-get-a-layer-to-appear-on-map/m-p/1246285#M79811 ReneRubalcava 2023 - 01 - 07 - t19:13:15z