1、下载4.3api,将文件夹放在C:\inetpub\wwwroot下,目录如下:C:\inetpub\wwwroot\4.3\4.3
2、复制4.3文件夹至vs项目管理中
3、修改init.js和dojo/dojo.js文件
如图所示,当然要修改vs指定端口,属性中修改
4、代码需要加 djConfig="parseOnLoad: true
我的测试代码如下html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Get started with SceneView - Create a 3D map</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="http://localhost:5374/4.3/4.3/esri/css/main.css">
<script type="text/javascript" src="http://localhost:5374/4.3/4.3/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" src="http://localhost:5374/4.3/4.3/init.js"></script>
<script>
require([
"esri/config",
"esri/core/urlUtils",
"esri/Map",
"esri/views/SceneView",
"esri/layers/FeatureLayer",
"dojo/domReady!"
], function(esriConfig,urlUtils,Map, SceneView,FeatureLayer){
// esriConfig.request.proxyUrl = "<url_to_proxy>";
// <!-- esriConfig.defaults.io.alwaysUseProxy = false; -->
// urlUtils.addProxyRule({
// urlPrefix: "route.arcgis.com",
// proxyUrl: "<url_to_proxy>"
// });
var featureLayer = new FeatureLayer("http://192.168.106.33:6080/arcgis/rest/services/province84/MapServer/0",{})
var map = new Map({
basemap: "streets",
ground: "world-elevation",
layers:[featureLayer]
});
var view = new SceneView({
container: "viewDiv", // Reference to the scene div created in step 5
map: map, // Reference to the map object created before the scene
scale: 50000000, // Sets the initial scale to 1:50,000,000
center: [121, 35] // Sets the center point of view with lon/lat
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>