ArcGIS JavaScript API错误-“无法加载文件”

ArcGIS JavaScript API Error - "Unable to Load File"

本文关键字:加载 文件 JavaScript API 错误 ArcGIS      更新时间:2023-09-26

我一直得到以下错误时,试图提供我的代码与一个webmap id与ESRI教程ArcGIS在线Web地图:

https://i.stack.imgur.com/xThVs.jpg

下面是我目前使用的Javascript代码。

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Create a Web Map</title>
        <link rel="stylesheet" type="text/css"
            href="http://js.arcgis.com/3.9/js/esri/css/esri.css" />
        <style>
            html, body, #mapDiv,.map.container{
                padding:0;
                margin:0;
                height:100%;
            }
            #legendDiv{
                background-color: #fff;
                postion: absolute !important;
                z-index: 99;
                top:10px;
                right:20px;
            }
        </style>
        <script>var dojoConfig = { parseOnLoad:true };</script>
        <script src="http://js.arcgis.com/3.9compact/"></script>
        <script>
            var map;
            require([
                    "esri/map",
                    "esri/arcgis/utils",
                    "esri/dijit/Legend",
                    "dojo/domReady!"
                    ], function(Map, arcgisUtils, Legend){
                arcgisUtils.createMap("08fdfee37898470385ad4b3752db969f", "mapDiv").then(function
             (response) {
                    map = response.map;
                var legend = new Legend({
                    map: map,
                    layerInfos:(arcgisUtils.getLegendLayers(response))
                }, "legendDiv");
                legend.startup();
                });
            });
        </script>
    </head>
    <body>
        <div id="mapDiv"></div>
        <div id="legendDiv"></div>
    </body>
</html>

地图id是弗吉尼亚州里士满历史遗址的公开地图

相同的代码在我的浏览器中工作正常,没有任何错误。你那边的网速可能很慢。第二个错误是因为网速慢。不确定第一个错误。

我试了同样的代码,它工作得很好。

根据您的屏幕截图,您正在尝试从本地系统打开文件。

为了能够成功加载此页面,您需要在web服务器(IIS, tomcat等)中部署此页面。