An example of combining Google Maps API with ArcGIS javascript API for Gmaps

Source: Internet
Author: User

(1) create a simple Google map page, which can be found in the Google Maps documentation.

 

(2) Add reference of ArcGIS javascript API to Javascript, for example:

<MCE: script src = "http://serverapi.arcgisonline.com/jsapi/gmaps? V = 1.4 "mce_src =" http://serverapi.arcgisonline.com/jsapi/gmaps? V = 1.4 "type =" text/JavaScript "> </MCE: SCRIPT> 

 

(3) Use WebService in the initialize () function to create a layer provided by ArcGIS online, for example:

VaR dynamicmap = new ESRI. ArcGIS. Gmaps. dynamicmapservicelayer <br/> ("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer ") 

 

(4) add this layer to the GMAP object, for example:

GMAP. addoverlay (mapservicelayer ); 

 

(5) Save and open it in the browser.

 

There is another more flexible method to load the layers obtained by external services.

 

(3) Use the constructor with four parameters to create a layer object in initialize (), for example:

VaR dynamicmap = new ESRI. ArcGIS. Gmaps. dynamicmapservicelayer <br/> ("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer", <br/> null, 0.75, dynmapcallback ); 

 

The four parameters are:

1. Map Service URL

2. Image Format parameter, set to null

3. Transparency: 0-1. The smaller the number, the more transparent it is.

4. callback function. That is, after executing this constructor, execute this function immediately. And pass itself as a parameter to the callback function.

(4) add this layer to GMAP In the callback function.

Function dynmapcallback (mapservicelayer) {<br/> GMAP. addoverlay (mapservicelayer); <br/>} 



 

 

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.