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"