arcgis api for js展示地图时报错
以下是我的代码,感觉是跨域问题,但是我已经配置了proxyUrl
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Test Map</title>
<style>
html,
body,
#viewDiv {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
<link rel="stylesheet" href="https://localhost/arcgis_js_v4 ... gt%3B
<script src="https://localhost/arcgis_js_v4 ... gt%3B
<script src="https://localhost/arcgis_js_v4 ... gt%3B
<script>
var myMap, view;
require([
"esri/Basemap",
"esri/layers/TileLayer",
"esri/layers/ElevationLayer",
"esri/Map",
"esri/views/MapView",
"esri/views/SceneView",
"esri/Ground",
"dojo/domReady!"
], function (Basemap, TileLayer, ElevationLayer, Map, MapView, SceneView, Ground){
// --------------------------------------------------------------------
// If you do not have public Internet access then use the Basemap class
// and point this URL to your own locally accessible cached service.
//
// Otherwise you can just use one of the named hosted ArcGIS services.
// https://services.arcgisonline. ... erver
// --------------------------------------------------------------------
config.request.proxyUrl="http://localhost/DotNet/proxy.ashx ";
config.request.alwaysUseProxy=false;
var layer = new TileLayer({
url: "http://172.18.8.135:6080/arcgi ... ot%3B
});
var customBasemap = new Basemap({
baseLayers: [layer],
title: "Custom Basemap",
id: "myBasemap"
});
var elevationLayer = new ElevationLayer({
url: "http://172.18.8.135:6080/arcgi ... ot%3B
});
myMap = new Map({
basemap: customBasemap,
//ground:"world-elevation"
ground: new Ground({layers:[elevationLayer]})
});
view = new SceneView({
center: [120, 36], // long, lat
container: "viewDiv",
map: myMap,
zoom: 6
});
});
</script>
</head>
<body class="claro"></body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<title>Test Map</title>
<style>
html,
body,
#viewDiv {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
<link rel="stylesheet" href="https://localhost/arcgis_js_v4 ... gt%3B
<script src="https://localhost/arcgis_js_v4 ... gt%3B
<script src="https://localhost/arcgis_js_v4 ... gt%3B
<script>
var myMap, view;
require([
"esri/Basemap",
"esri/layers/TileLayer",
"esri/layers/ElevationLayer",
"esri/Map",
"esri/views/MapView",
"esri/views/SceneView",
"esri/Ground",
"dojo/domReady!"
], function (Basemap, TileLayer, ElevationLayer, Map, MapView, SceneView, Ground){
// --------------------------------------------------------------------
// If you do not have public Internet access then use the Basemap class
// and point this URL to your own locally accessible cached service.
//
// Otherwise you can just use one of the named hosted ArcGIS services.
// https://services.arcgisonline. ... erver
// --------------------------------------------------------------------
config.request.proxyUrl="http://localhost/DotNet/proxy.ashx ";
config.request.alwaysUseProxy=false;
var layer = new TileLayer({
url: "http://172.18.8.135:6080/arcgi ... ot%3B
});
var customBasemap = new Basemap({
baseLayers: [layer],
title: "Custom Basemap",
id: "myBasemap"
});
var elevationLayer = new ElevationLayer({
url: "http://172.18.8.135:6080/arcgi ... ot%3B
});
myMap = new Map({
basemap: customBasemap,
//ground:"world-elevation"
ground: new Ground({layers:[elevationLayer]})
});
view = new SceneView({
center: [120, 36], // long, lat
container: "viewDiv",
map: myMap,
zoom: 6
});
});
</script>
</head>
<body class="claro"></body>
</html>
0 个回复