ArcGIS Server JavaScript API practice (1)

Source: Internet
Author: User

The previous article briefly introduced how to use arcgis server to deploy maps, and then discussed how to use ArcGIS Server JavaScript API to operate and display maps.

 

Because arcgis server has just launched the JavaScript API in version 9.3, the only document available for reference is the document provided by esri. Before reading this article, we recommend that you go to esri's website to check the document. It provides a lot of examples and instructions, which is the best place for beginners. This article is based on this. This document is not currently available for download and is only available for online reading.

Http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp_start.htm

 

In the previous article, we mainly talked about the map display. Here we mainly talk about the problems encountered.

As far as I know,If you use the ArcGIS Server JavaScript API to display a map, you must connect to the Internet..

The following HTML page shows a map using the local ArcGIS Server Service:

<! Doctype HTML public "-// W3C // dtd html 4.01 // en" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> Create A Map </title>
<LINK rel = "stylesheet" type = "text/CSS" href = "http://serverapi.arcgisonline.com/jsapi/arcgis/1.1/js/dojo/dijit/themes/tundra/tundra.css">
<SCRIPT type = "text/JavaScript" src = "http://serverapi.arcgisonline.com/jsapi/arcgis? V = 1.1 "> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Dojo. Require ("ESRI. Map ");
Function init (){
Var myMap = new esri. Map ("mapDiv ");
Var dynamicMapServiceLayer = new esri. layers. ArcGISDynamicMapServiceLayer ("http: // rzf: 8399/arcgis/rest/services/test_2/MapServer ");
MyMap. addLayer (dynamicMapServiceLayer );
}

Dojo. addonload (init );
</SCRIPT>
</Head>
<Body class = "tundra">
<Div id = "mapdiv" style = "width: 900px; Height: 600px; Border: 1px solid #000;"> </div>

<H4> Work Flow: </H4>
<Ul>
<Li> create a map. </LI>
<Li> Add an arcgistiledmapservicelayer. </LI>
</Ul>
</Body>
</Html>

 

The effect is as follows:
See the following two lines:
<Link rel = "stylesheet" type = "text/css" href = "http://serverapi.arcgisonline.com/jsapi/arcgis/1.1/js/dojo/dijit/themes/tundra/tundra.css">
<Script type = "text/javascript" src = "http://serverapi.arcgisonline.com/jsapi/arcgis? V = 1.1 "> </script>
This is to go to the esri website to open two files. Obviously, if the network is disconnected, the map will not be displayed.

For this reason, I will first download these two files and save them to the repository, named default.jsand tundra.css, and then reference them like referencing common js and css files:
<Link rel = "stylesheet" type = "text/css" href = "tundra.css">
<Script type = "text/javascript" src = "default. js"> </script>
This is the same as the previous one, but the map display speed should be faster, especially when the network is relatively slow.

As a result, it seems that the problem has been solved, but after my practice, I still cannot solve it completely: when the network is disconnected or the network is unstable, the map still cannot be displayed.
The reason is as follows:
Open the downloaded default. js file, you can see that there is such a sentence: esriConfig = {baseUrl: "http://serverapi.arcgisonline.com/jsapi/arcgis/1"
It still needs to go to the esri website to download files. As a result, all the work is done!
What should I do?
Continue to put all the files down like the front?
However, when I try to open the file http://serverapi.arcgisonline.com/jsapi/arcgis/1/, the page displays:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
This is just a directory, and the address of the file to be used has not yet come out.
Continue to view the default. js file and find that the file address is hidden in it, for example:
EsriDijitConfig = {infoWindow: {templatePath: esriConfig. baseUrl + "js/esri/dijit/templates/infodesktailhtml"
The actual address is: http://serverapi.arcgisonline.com/jsapi/arcgis/1/js/esri/dijit/templates/InfoWindow.html

Now you can open and save the file.

However, how many files are referenced in default. js? What are their addresses? In this way, I will query them one by one?

Take a look at default. I gave up the idea of js files: the code is a line to the end, never branch, and it is very inconvenient to view-it is clear that esri does not want us to read this file, so it is hard to read it, how can I analyze it and find out the URLs ?!

 

Now, I have to give up.

In fact, I really don't understand what esri thinks. Do we need to ensure smooth network connection when using JavaScript APIs? Does it provide these files to us? In the same network environment, the adf can be displayed normally. It seems that the newly launched JavaScript API method has to be improved slowly.

We are waiting for a try.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.