1. Apply for a key value for a Google Map
2. Add the following code to the page:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> </title>
<SCRIPT src = "http://maps.google.com/maps? File = API & amp; V = 2 & amp; sensor = true & amp; Key = secret & H1 = ZH "type =" text/JavaScript "> </SCRIPT>
<Script language = "JavaScript" type = "text/JavaScript">
VaR map;
VaR geoxml;
Function initialize (){
If (gbrowseriscompatible ()){
Geoxml = new ggeoxml ("http: // www. *****. com/data. xml" + "? RND = "+ math. Random ());
Map = new gmap2 (document. getelementbyid ("map_canvas "));
Map. enablescrollwheelzoom ();
VaR bottomright = new gcontrolposition (g_anchor_bottom_right, new gsize (10, 10 ));
Map. addcontrol (New glargemapcontrol (), bottomright );
Map. addcontrol (New gmaptypecontrol ());
// Coordinate point: (latitude, longitude)
Map. setcenter (New glatlng (39.904, 116.389), 11 );
Map. openinfowindow (Map. getcenter (), document. createtextnode ("Hello, world "));
}
}
</SCRIPT>
</Head>
<Body onload = "initialize ();" onUnload = "gunload ();">
<Div id = "map_canvas" style = "width: 523px; Height: 305px;"> </div>
</Body>
</Html>
3. The data. XML data format is as follows:
<? XML version = "1.0" encoding = "UTF-8"?>
<Kml xmlns = "http://earth.google.com/kml/2.1">
<Document>
<Style id = "highlightplacemark">
<Iconstyle>
<Icon>
<Href> http://maps.google.com/mapfiles/kml/paddle/red-stars.png </Icon>
</Iconstyle>
</Style>
<Placemark>
<Name> National theatre </Name>
<Styleurl> # highlightplacemark </styleurl>
<Description>
<! [CDATA [
<H1> CDATA tags are useful! </H1>
<P> <font color = "red"> China is <I> more readable </I> and
<B> easier to write </B> when you can avoid using entity
References. </font> </P>
]>
</Description>
<Point>
<Coordinates>
116.389751, 39.904729
</Coordinates>
</Point>
</Placemark>
</Document>
<! -- Note: When you set the location, the first path is used, and the second latitude is opposite to the setcenter In the JS setting center -->
</Kml>
4. Run, OK
Click here to download the source file:/files/wenming205/google xml.rar