< Html >
< Head >
< Title > Load Google Map </ Title >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
< Script
SRC = "Http://ditu.google.com/maps? File = API & amp; V = 2 & amp; Key = ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA & HL = ZH-CN"
Type = "Text/JavaScript" > </ Script >
< Script Type = "Text/JavaScript" >
Function Load (){
// Check the compatibility of the browser.
If (Gbrowseriscompatible ())
{
// Load Map
VaR Map = New Gmap2 (document. getelementbyid ( " Mapcanvas " ));
// Set the central coordinates of the map. (glatlng (longitude, latitude), zoom leavel)
// Zoom leavel (maxvalue = 1, the greater the value, the smaller the zoom leavel)
Map. setcenter ( New Glatlng ( 39.990168 , 116.295304 ), 5 );
// Map. setcenter (New glatlng (23.352697196375434, 103.4267520904541), 18 );
}
}
</ Script >
</ Head >
< Body Onload = "Load ()" OnUnload = "Gunload ()" >
<! -- Map canvas -->
< Div ID = "Mapcanvas" Style = "Width: 800px; Height: 600px" > </ Div >
</ Body >
</ Html >
2. Set general attributes of a map
(1) map. continuouszoomenabled () -- determine whether the map supports Continuous scaling;
Map. enablecontinuouszoom ()/map. disablecontinuouszoom () method to switch whether Continuous scaling is allowed;
(2) scroll wheel scaling -- map. enablescrollwheelzoom ()/map. disablescrollwheelzoom ()
(3) double-click zoom -- map. enabledoubleclickzoom ()/map. disabledoubleclickzoom ()
(4) map dragging (default) -- draggingenabled () determines whether a map can be dragged, enabledragging ()/disabledragging ()
(5) Information Window-a bubble annotation can be displayed on the map to display information. infographic wenabled () Judgment, enableinfowindow ()/disableinfowindow
(6) Add a search bar
3. Map type
Map. setmaptype (g_satellife_map );// Modify the map type to a satellite map
Hybrid map --G_hybrid_mapDefault Value --G_nomal_map