ArcGIS JavaScript api 4.14 deploy offline quote

1. Download

  https://esrisoftware.esri.com/akdlm/software/ArcGIS_JavaScript/4.14/arcgis_js_v414_api.zip

 The official address

2. Deploy

  • The offline download arcgis api 4.14 wwwroot decompression copied to the directory in the path before 4.14 folder C: \ inetpub \ wwwroot \ arcgis_js_v414_api \ arcgis_js_api \ library:

  •  C:\inetpub\wwwroot\arcgis_js_v414_api\arcgis_js_api\library \4.14\init.js ;


  • init.js file inside, global search  [HOSTNAME_AND_PATH_TO_JSAPI] , then replace api deployment path on a local machine, I the following configuration: https://127.0.0.1:6636 /arcgis_js_api/library/4.14

  • Similarly, configure the C: \ inetpub \ wwwroot \ arcgis_js_v414_api \ arcgis_js_api \ library \ 4.14 \ dojo \ dojo.js file

    Global Search  [HOSTNAME_AND_PATH_TO_JSAPI] , then replace api deployment path on the local machine, my configuration is as follows: HTTPS: //127.0.0.1:6636/arcgis_js_api/library/4.14/

3. Test

Test code, there is a problem needs attention :

The official version of the reference line, the call is 4.14 js directory can be, and need to refer to init.js js references in the offline version.

 

 

 

 

Copy the code
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Intro to MapView - Create a 2D map - 4.10</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
 
<link rel="stylesheet" href="http://127.0.0.1:6636/arcgis_js_api/library/4.14/esri/css/main.css">
<script src="http://127.0.0.1:6636/arcgis_js_api/library/4.14/init.js"></script>
 
<script>
require([
"esri/Map",
"esri/views/MapView"
], function(Map, MapView) {
 
var map = new Map({
basemap: "streets"
});
 
var view = new MapView({
container: "viewDiv",
map: map,
zoom: 4,
center: [15, 65] // longitude, latitude
});
 
});
</script>
</head>
 
<body>
<div id="viewDiv"></div>
</body>
</html>
Copy the code

In the case of the Internet, the map can be loaded out, indicating successful deployment offline

 

4. Cross-domain error

           Offline version 3.x deployment no such problem, therefore, need to add cross-domain in IIS to read:

    • Open the IIS interface, click HTTP response headers

    • Can be seen on the right to add, and then add the following to the header
      Access-Control-the Allow-Headers: the Type-the Content, api_key, the Authorization
      Access-Control-the Allow-Origin: *

    •  

       

Guess you like

Origin www.cnblogs.com/googlegis/p/12417063.html