Starting from the basics: combining Google maps with custom maps (unfinished)

Source: Internet
Author: User
The source code is as follows:
<SCRIPT src = "http://maps.google.com/maps? File = API & V = 2 & Key = abqiaaaazdzk-_ WVFMrLCR5HmP2HRxR0f4x-N4Qfvu9mjgqbvEL2dZR5HxQqctZ25BjEMADNS3Mtrs35g-bXAw"
Type = "text/JavaScript"> </SCRIPT>
<SCRIPT src = "http://serverapi.arcgisonline.com/jsapi/gmaps? V = 1 "type =" text/JavaScript "> </SCRIPT>
<SCRIPT type = "text/JavaScript">
VaR GMAP = NULL;

Function initialize (){
GMAP = new gmap2 (document. getelementbyid ("GMAP "));
VaR centerat = new glatlng (0, 0 );

GMAP. addcontrol (New glargemapcontrol ());
GMAP. addcontrol (New gmaptypecontrol ());
GMAP. setcenter (centerat, 1 );
VaR dynamicmap = new ESRI. ArcGIS. Gmaps. dynamicmapservicelayer
("Http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer ",
Null, 0.75, dynmapcallback );

}

/*
* Gevent. addlistener (dynamicmap, "LOAD", function addlayer (mapservicelayer ){
GMAP. addoverlay (mapservicelayer );
})
VaR map = new gmap2 (document. getelementbyid ("GMAP "));
Map. setcenter (New glatlng (37.4419,-122.1419), 13 );

Gevent. addlistener (MAP, "click", function (){
Alert ("You clicked the map .");
});
*/
Function dynmapcallback (mapservicelayer ){
// GMAP. addoverlay (mapservicelayer );
}
</SCRIPT>
The first two scripts in this Code point to the Services released by Google map API and ArcGIS online. With these two scripts, you can call the objects and methods in Google map. From the second ESRI script, it seems that a lot of code is used, so it may be difficult to use your own ArcGIS Server to publish a similar service, I do not know how to register my service on ArcGIS online.
Go to the custom JavaScript code.
First, declare an empty GMAP object, and then use new gmap2 (element) in inialize for instantiation. element is a map element in the Dom. In this way, a map resource is obtained, but for a map in a small window of the browser, you also need to specify the display center and controller. You can also add scales and initial display proportions. The display center is represented by a glatlng object. To construct a glatlng, the longitude and latitude parameters are required. The generated code is new glatlng (Lat, LNG). After being generated, the setcenter (glatlng, scale) of GMAP is used) A function is used for maps. scale is a number. It should be the 10-level scale in Google.
GMAP. addcontrol (New glargemapcontrol ());
GMAP. addcontrol (New gmaptypecontrol ());
These two lines of code implement the function of adding a map controller, which is more common and simple. There is nothing to say.

VaR dynamicmap = new ESRI. ArcGIS. Gmaps. dynamicmapservicelayer
("Http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer ",
Null, 0.75, dynmapcallback );
This code generates a map customized by the user on the server and released to ArcGIS online. (Unfinished, to be continued)

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.