Accustomed to the development of the GoogleMap API, we all want to use this development method, to do some HTML static page development, or PHP page development, we do not have to care about how the server management and development.
Here we use Supermap Iserver 2.0 JS SDK To configure an environment that allows online development, the process is simpler:
1, we use Supermap Iserver with the demo handler to respond to requests, then here we simply modify the Demo/scripts/supermap.include.js file, add Demo server's IP address, as follows:
SuperMap.Include.js
1 var ipAddr = "http://127.0.0.1:7080/demo/";
2 function _IncludeScript(inc){
3 var script='<'+'script type="text/javascript" src="' + ipAddr +'scripts/'+inc+'"'+'><'+'/script>';
4 document.writeln(script);
5 }
6
7 function _IncludeStyle (inc){
8 var style='<'+'link type="text/css" rel="stylesheet" href="'+ ipAddr + 'styles/'+inc+'"'+' />';
9 document.writeln (style);
10
This allows the Web page to correctly reference all script library files;
2. In addition to static pages, there are cross-domain problems with other application calls, so here, add a Cross-domain profile for the root folder in Tomcat, as follows:
ClientAccessPolicy.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <access-policy>
3 <cross-domain-access>
4 <policy>
5 <allow -from>
6 <domain uri="*"/>
7 </allow-from>
8 <grant-to>
9 <resource path="/" include-subpaths="true"/>
10 </grant-to>
11 </policy>
12 </cross-domain-access>
13 </access-policy>
14
15
3, start the GIS server and Web server, write a static page to test it
Test.html
1 2 3 <link href="http://127.0.0.1:7080/demo/styles/main.css" rel="stylesheet"></link>
4 <link href="http://127.0.0.1:7080/demo/styles/page.css" rel="stylesheet"></link>
5 <script language='javascript' src='http://127.0.0.1:7080/demo/scripts/SuperMap.Include2.js'></s cript>
6 <script type="text/javascript" src="http://127.0.0.1:7080/demo/scripts/page_resource_zh.js"></sc ript>
7 <script type="text/javascript" src="http://127.0.0.1:7080/demo/scripts/page.js"></script>
8 9 <!--这里偷懒,利用了SuperMap自带的page.js方法 ,当然里面也做了部分修改,就是写明Handler地址和GIS服务地址即可-- >
10 <body onload="onPageLoad()">
11 <div id="mapcontrol1Div" style="position: absolute; top:109px; left: 216px;width:799;height:629"></div>
12 </body>
13
Over