Google Maps in applications

Source: Internet
Author: User

Google map is implemented in the project:

First you need to introduce the <SCRIPT src = "http://maps.google.com/maps? File = API & amp; V = 2 & amp; sensor = true & amp; Key = ABQIAAAAY92WzbL-lY1eE3IPdMNEvRSWy9ILSfG2C6fHg9Q_Zaz2MxGGORSOFohA5OJsZ76dORjdamlymzeWvg "type =" text/JavaScript "> </SCRIPT>

.

<SCRIPT type = "text/JavaScript">

Function initialize (){
VaR lat = Document. getelementbyid ("Lat"). value; // degree
VaR lng = Document. getelementbyid ("LNG"). value; // longitude
VaR size = 15; // map multiple: 1-23
VaR message = Document. getelementbyid ("name"). value;
If (gbrowseriscompatible ()){
VaR map = new gmap2 (document. getelementbyid ("map_del "));
Map. setcenter (New glatlng (Lat, LNG), size); // map coordinate information
Map. addcontrol (New gsmallzoomcontrol (); // scaling button control
Map. addcontrol (New ghierarchicalmaptypecontrol (); // nested map Type Control
}
VaR markobj = new gmarker (New glatlng (Lat, LNG), {draggable: true}); // Add icon
Markobj. openinfowindowhtml (Message); // The message is displayed.
Gevent. addlistener (markobj, "Mouseover", function () {// Add a Time Message
Markobj. openinfowindowhtml (Message );
});
Map. addoverlay (markobj );
}
Window. onload = initialize;
</SCRIPT>

Sometimes, you may find that keys are required when the project is running on the server.

You need to register Google map API from http://code.google.com/intl/zh-cn/apis/maps/signup.html,

In my text box, you can enter your IP address or your domain name (www.962.16.net ),

Then modify the generated key. In the following example, I generated the key with 192.168.1.44. We can notice that there is a key/value in the middle, sensor = true_or_false, and change it to sensor = true.

 
<SCRIPT src = "http://maps.google.com/maps? File = API & amp; V = 2 & amp; sensor =True_or_false& Amp; Key = ABQIAAAAY92WzbL-lY1eE3IPdMNEvRSIMweZSjbRtcUk2F5YNqLnri0MahQISU-YWznLEfyyR0a3619ZnoYkuQ "type =" text/JavaScript "> </SCRIPT>...
 
A little more"
 
Generally, when we release a project to the server, we need to modify the key value. Then we only need to put the key in webconfig,
<SCRIPT type = "text/JavaScript" src = "<% = readgoogle %>"> </SCRIPT>
 
Page Background:
 
Public String readgoogle = "";
 
Public void page_load (Object sender, eventargs E)
 
{
 
Readgoogle = configurationmanager. etettings ["maps"]. tostring ();
 
}
 
Webconfig Configuration
 
<Deleetask> <add key = "maps" value = "http://maps.google.com/maps/api/js? Sensor = true "/> </appsettings>

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.