我创建了一个精确的示例示例,并在尝试运行它时。我收到很多错误。有人能告诉我如何解决这个问题吗?
https://developers.arcgis.com/javascript/jssamples/gp_popuplink.html
这是错误之一:
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied { response={...}, xhr=XMLHttpRequest, code=1012, mor
我还包括以下整个工作代码:
<!DOCTYPE html>
<html>
<head>
<title>Create a Web Map</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.11/esri/css/esri.css">
<style>
html,body,#mapDiv,.map.container{
padding:0;
margin:0;
height:100%;
}
#legendDiv{
background-color: #fff;
position: absolute !important;
z-index: 99;
top:10px;
right:20px;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://js.arcgis.com/3.11compact/"></script>
<script>
var map,
webmapId = "1a40fa5cc1ab4569b79f45444d728067";
require([
"esri/map",
"esri/arcgis/utils",
"esri/dijit/Legend",
"dojo/domReady!"
], function (Map, arcgisUtils, Legend) {
arcgisUtils.createMap(webmapId, "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>
答案 0 :(得分:0)
您错过了配置的重要部分。从你得到的错误中可以看出,你的esrimap正在获取一个糟糕的网址。那是因为您没有设置服务器,如您所指的示例中所示:
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
config.defaults.geometryService = new GeometryService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer");
Here's一个关于Plunker的简单示例。
var map;
require([
"esri/map",
"esri/arcgis/utils",
"esri/tasks/GeometryService",
"esri/config",
], function(
Map,
arcgisUtils,
GeometryService,
config
) {
config.defaults.geometryService = new GeometryService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer");
config.defaults.io.proxyUrl = "/proxy/";
arcgisUtils.createMap("a193c5459e6e4fd99ebf09d893d65cf0", "mapDiv").then(function(response){
window.map = response.map;
});
});