Code
<! Doctype HTML public "-// 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" Xmlns: V = "Urn: Schemas-Microsoft-com: VML" >
< Head >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" />
< Title > Google map javascript API example: tag a drag event </ Title >
< Script SRC = "Http://ditu.google.cn/maps? File = API & amp; V = 2 & amp; Key = ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA & HL = ZH-CN"
Type = "Text/JavaScript" > </ Script >
< Script Type = "Text/JavaScript" >
Function Initialize (){
If (Gbrowseriscompatible ()){
VaR Map = New Gmap2 (document. getelementbyid ( " Map_canvas " ));
VaR Center = New Glatlng ( 39.917 , 116.397 );
Map. setcenter (center, 14 );
VaR Marker = New Gmarker (center, {draggable: True });
Gevent. addlistener (Marker, " Dragstart " , Function (){
Map. closeinfowindow ();
});
Gevent. addlistener (Marker, " Dragend " , Function (){
// Marker. openinfowindowhtml ("rebounding ...");
VaR Custpoint = Marker. getpoint ();
Alert ( " Longitude " + Custpoint. LNG () + " Latitude " + Custpoint. LAT ())
});
Map. addoverlay (Marker );
}
}
</ Script >
</ Head >
< Body Onload = "Initialize ()" OnUnload = "Gunload ()" >
< Div ID = "Map_canvas" Style = "Width: 500px; Height: 300px" > </ Div >
</ Body >
</ Html >