核心提示:Arcgis for javascriptapi本地部署教程1. 官网下载api和sdk 需要自己注册用户2. 解压,放到项目中3. 修改两个文件 arcgis_js_api\library\...
Arcgis for javascriptapi本地部署教程
1. 官网下载api和sdk 需要自己注册用户
2. 解压,放到项目中
3. 修改两个文件 arcgis_js_api\library\3.22\3.22\init.js 和arcgis_js_api\library\3.22\3.22\dojo\dojo.js
找到 [HOSTNAME_AND_PATH_TO_JSAPI],替换为本地路径,例:"主机:端口\arcgis_js_api\library\3.22\3.22\"
这个路径需要根据自己放置的路径调整
测试例子
<!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>Simple Map</title> <style> html, body, #map { height: 100%; margin: 0; padding: 0; } </style> <link rel="stylesheet" type="text/css" href="https://主机:端口/arcG322/js/arcgis_js_api/library/3.22/3.22/esri/css/esri.css" /> <script src="https://主机:端口/arcG322/js/arcgis_js_api/library/3.22/3.22/init.js"></script> <script> var map; require(["esri/map", "dojo/domReady!"], function(Map) { map = new Map("map", { basemap: "streets", //For full list of pre-defined basemaps, navigate to https://arcg.is/1JVo6Wd center: [-122.45, 37.75], // longitude, latitude zoom: 13 }); }); </script> </head> <body> <p id="map"></p> </body> </html>
遇到的问题: 通过Hbuilder写项目没有问题,但是应用的具体开发项目,出现错误,把上面两个修改地方的https改为http则正常