Copy Code code as follows:
<script language= "javascript" type= "Text/javascript" >
Add by Ahuinan 2009-8-17
Initialize (23.165613663312594,113.35968017578125)
var map;
var Gdir;
var marker2;
var hasmarker = false;
var hotellatlng = new Glatlng (<%=initxy%>)//Initialize hotel coordinates
var polyline;
var points = [];
POINTS[1] = HOTELLATLNG;
function Initialize () {
if (gbrowseriscompatible ()) {
Map = new GMap2 (document.getElementById ("Divmap"), {googlebaroptions: {showonload:true}});
Gdir = new Gdirections (map);
Map.setcenter (HOTELLATLNG, 9);
Map.addcontrol (New Goverviewmapcontrol ());
Map.addcontrol (New Glargemapcontrol ());
Join Search Box
Map.enablegooglebar ();
Map.enablescrollwheelzoom ();
Create a hotel callout, not drag
var hotelmarker = new Gmarker (new glatlng (<%=initxy%>));
Map.addoverlay (Hotelmarker);
The left mouse button can create a marker,
Gevent.addlistener (Map, "click", Function (OVERLAY,LATLNG,OVERLAYLATLNG) {
if (latlng = null | | hasmarker = = TRUE) {
Return
}
var Greenicon = new Gicon (G_default_icon);
Greenicon.image = ".. /googlemap/green-dot.png ";
Greenicon.iconsize = new Gsize (32,32);
Greenicon.iconanchor = new Gpoint (16,32);
Greenicon.shadowsize=new gsize (56,33);
Marker2 = new Gmarker (Latlng,{draggable:true,icon:greenicon});
Map.addoverlay (MARKER2);
Gevent.addlistener (Marker2, "Dragend", function () {
Points[0] = MARKER2.GETLATLNG ();
Gdir.loadfromwaypoints (points,{"Preserveviewport": true});
})
Gevent.addlistener (Gdir, "Addoverlay", function () {
for (var i=0; I<=gdir.getnumroutes (); i++) {
var originalmarker = Gdir.getmarker (i);
Map.removeoverlay (Originalmarker);
}
Polyline = Gdir.getpolyline ();
Polyline.setstrokestyle ({color: "Red", weight:2,opacity:1});
Map.addoverlay (polyline);
});
Hasmarker = true;
Points[0] = latlng;
Gdir.loadfromwaypoints (points,{"Preserveviewport": true});
})
}
}
Press the Add button
function Add () {
if (points.length = = 1) {
Alert ("No Line, terminate operation");
}else{
Window.opener.document.getElementById ("Txthi_mapmarkdesc"). Value = Window.opener.document.getElementById ("Txthi_ Mapmarkdesc "). value+" \ n "+document.getelementbyid (" Txtname "). value+" | | | " +document.getelementbyid ("Txttype"). value+ "| | | |" +points[0]+ "\ n";
Window.close ();
}
}
Window.onload = function () {
Initialize ()
}
</script>