The simplest google map code

Source: Internet
Author: User

Register and use Google map to log on first
Http://code.google.com/intl/zh-cn/apis/maps/signup.html,
The Code obtained after application is added to the webpage. The following is a simple example.
<! DOCTYPE html "-// W3C // dtd xhtml 1.0 Strict // EN"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>
<Title> Google Maps JavaScript API Example </title>
<Script src = "http://ditu.google.cn/maps? File = api & amp; v = 2 & amp; key = abcdefg & sensor = true_or_false"
Type = "text/javascript"> </script>
<Script type = "text/javascript">
 
Function wb (){
If (GBrowserIsCompatible ()){
Var map = new GMap2 (document. getElementById ("webmap "));
Map. setCenter (new GLatLng (88, 99), 11 );
}
}
 
</Script>
</Head>
<Body onunload = "GUnload ()">
<Div id = "webmap" style = "width: 500px; height: 500px"> </div>
</Body>
</Html>
In the example
A uses the script tag to include Google map API JavaScript.
B. Create a div element named "webmap" to include the map.
C. Compile JavaScript Functions to create a "map" object.
D. Set the center of the map to the specified geographic point.
E. initialize the map object from the onLoad event of the body Tag.
Map. setCenter (new GLatLng (88, 99), 11); The parameter "88,99" indicates the longitude and latitude of the location, and "11" indicates the scaling size to obtain
You can use the map to find your location, and right-click "what is this" in the menu to display the coordinates in the search box.

Author: "java learning"

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.