gpt4 book ai didi

javascript - ArcGIS API for JavaScript,NS_ERROR_DOM_BAD_URI : Access to restricted URI denied

转载 作者:行者123 更新时间:2023-12-03 07:21:30 28 4
gpt4 key购买 nike

我正在遵循本指南:

https://developers.arcgis.com/javascript/jshelp/intro_agstemplate_amd.html

我正在使用他们在教程中使用的网络 map ID:1a40fa5cc1ab4569b79f45444d728067

但是,当我运行我的代码时:

var map;
require([
"esri/map",
"esri/arcgis/utils",
"dojo/domReady!"
], function(Map, arcgisUtils) {
arcgisUtils.arcgisUrl = "file:///C:/Users/Bryan/Desktop/gis.html";
arcgisUtils.createMap("1a40fa5cc1ab4569b79f45444d728067 ", "mapDiv").then(function(response) {
map = response.map;
});
});

我收到以下错误:

NS_ERROR_DOM_BAD_URI: Access to restricted URI denied

在教程中他们说了以下内容:

To access a web map from a portal outside of ArcGIS Online, reference the arcgisUrl property and set the path to your portal URL before calling the createMap() method: arcgisUtils.arcgisUrl = "http://pathto/portal/sharing/content/items";

但是什么是门户 URL?我的门户网址是什么?

最佳答案

我们将逐步解决上述问题:

首先,您应该知道您正在使用的公共(public)或私有(private)网络 map ID 1a40fa5cc1ab4569b79f45444d728067。我的意思是每个人或创建它的人都可以访问它。

如您所见,我可以在全局范围内访问此 ID,因此这意味着它不是私有(private)的,因此您无需添加门户网址

(以下是访问网络 map 的两种方式,只需替换以下网址末尾的网络 map ID)。

上述网络 map ID 的项目详细信息: click here to see the details of webmap id.

map 查看器中的网络 map ID: click here to see webmap id in map viewer.

仅当网络 map ID 未共享给所有人时才需要门户网址。

<小时/>

Portal URL: 每当您注册 arcgis.com 后,它都会为每个用户创建一个唯一的门户 URL(安装 Portal for ArcGIS 的服务器名称)。仅当 webmap/item 不共享给所有人时,我们才需要配置这个唯一的 url。在这种情况下,它会自动获取“arcgis online 默认门户 url”。

<小时/>

现在转到 this online sample 并在那里替换您的网络 map ID。它将正常工作。

<小时/>

运行代码:

require([
"dojo/parser",
"dojo/ready",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dojo/dom",
"esri/map",
"esri/urlUtils",
"esri/arcgis/utils",
"esri/dijit/Legend",
"esri/dijit/Scalebar",
"dojo/domReady!"
], function(
parser,
ready,
BorderContainer,
ContentPane,
dom,
Map,
urlUtils,
arcgisUtils,
Legend,
Scalebar
) {
ready(function(){

parser.parse();

//if accessing webmap from a portal outside of ArcGIS Online, uncomment and replace path with portal URL
//arcgisUtils.arcgisUrl = "https://pathto/portal/sharing/content/items";
arcgisUtils.createMap("1a40fa5cc1ab4569b79f45444d728067 ","map").then(function(response){
//update the app
dom.byId("title").innerHTML = response.itemInfo.item.title;
dom.byId("subtitle").innerHTML = response.itemInfo.item.snippet;

var map = response.map;



//add the scalebar
var scalebar = new Scalebar({
map: map,
scalebarUnit: "english"
});

//add the legend. Note that we use the utility method getLegendLayers to get
//the layers to display in the legend from the createMap response.
var legendLayers = arcgisUtils.getLegendLayers(response);
var legendDijit = new Legend({
map: map,
layerInfos: legendLayers
},"legend");
legendDijit.startup();


});


});

});
<link rel="stylesheet" href="https://js.arcgis.com/3.16/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<link rel="stylesheet" href="http://developers.arcgis.com/javascript/sandbox/css/styles.css">

<script src="https://js.arcgis.com/3.16/"></script>

<body class="claro">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
<div id="header" class="shadow roundedCorners" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
<div id="title"></div>
<div id="subtitle"></div>
</div>
<div id="map" class="roundedCorners shadow" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
<div id="rightPane" class="roundedCorners shadow" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'right'" >
<div id="legend"></div>
</div>
</div>
</body>

关于javascript - ArcGIS API for JavaScript,NS_ERROR_DOM_BAD_URI : Access to restricted URI denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36198852/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com