1:下载 ArcGIS API For Javascript 官网下载好像要有账号并且国内邮箱账号注册好像不支持, 我也没找免费下在的地方,好像看到有篇博客写了怎么免费下载的方法,下次在找看到在试下,我会把在csdn用币下载的都放到网盘分享出来 2:按照官网的方法(网上好多博客也写了)先把两个js中的地址配置成losthost:8080,然后放到tomcat中如下: 参考这个html改js文件中那mapserver地址,我使用其它版本的时候地图出不来,改的js在浏览器开发者模式下看到报错不知道什么原因,后来我使用这个版本并把https改成了http,版本无所谓,4版本只是多支持了3d等功能 放到tomcat位置 Html代码直接使用 的官网的例子 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Simple Map</title> <link rel="stylesheet" type="text/css" href="http://localhost:8080/arcgis_js_api/library/3.22/3.22/esri/css/esri.css" /> <script src="http://localhost:8080/arcgis_js_api/library/3.22/3.22/init.js"></script> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script> require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "dojo/domReady!"], function(Map, ArcGISTiledMapServiceLayer) { var map = new Map("map"); //If you do not have Internet access then you will need to point this url to your own locally accessible tiled service. var tiled = new ArcGISTiledMapServiceLayer("https://services.arcgisonline.com/arcgis/rest/services/Ocean/World_Ocean_Base/MapServer"); map.addLayer(tiled); } ); </script> </head> <body> <div id="map" style="width:900px; height:600px; border:1px solid #000;"></div> </body> </html>
效果: |