我遵循这个指南:
我使用的是他们在教程中所做的Web: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:拒绝对受限URI的访问
在本教程中,他们说:
要从ArcGIS Online之外的门户访问web地图,请在调用createMap()方法之前引用arcgisUrl属性并设置门户URL的路径: arcgisUtils.arcgisUrl = "http://pathto/portal/sharing/content/items";
但是什么是门户URL呢?我的门户网址是什么?
发布于 2016-03-25 15:16:32
我们会循序渐进地解决上述问题:
首先,您应该知道您正在使用的you地图ID 1a40fa5cc1ab4569b79f45444d728067是公共的还是私有的。我的意思是,每个人或被创造它的人都可以使用它。
如您所见,我可以全局访问这个Id,这意味着它不是私有的,所以您不需要添加门户url
(下面是访问web地图的两种方法,只需在下面urls的末尾替换web地图id )。
上述Webmap ID的项目详细信息: 点击这里查看网站地图id的详细信息。
地图查看器中的Webmap ID: 单击此处查看地图查看器中的webmap id。
只有当webmap id不是每个人共享时,才需要门户url。
每当您注册到门户网址之后,它就会为每个用户创建一个惟一的门户url (安装了arcgis.com的服务器名)。这个唯一的url,我们需要配置时,只有当网页地图/项目不是共享给每个人。在这种情况下,它自动采取"arcgis在线默认门户url".。
现在转到这个在线样本,并在那里替换您的webmap 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>
https://stackoverflow.com/questions/36198852
复制相似问题