function map_go(){
  var s1 = document.getElementById("m_start");
  var s2 = document.getElementById("m_start2");
  var e1 = document.getElementById("m_end");
  var print_map = document.getElementById("map2");
  if(s1.value=='' || s2.value=='' || e1.value==''){
    alert("資料不完整，無法查詢");}
  else{
    var s3 = s1.value + s2.value;
    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;
    var start_icon = null;
    initialize(s3,e1.value);
  }
}

function initialize(form,to) {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map_canvas"));
    gdir = new GDirections(map, document.getElementById("directions"));

    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", LoadMapErrors);
    map.enableContinuousZoom(true);
    map.continuousZoomEnabled(true);
    map.addControl(new GLargeMapControl());
    setDirections(form, to);
  }
}


function setDirections(fromAddress, toAddress) {
gdir.load("from: " + fromAddress + " to: " + toAddress);
}

function LoadMapErrors(){
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("找不到此地址 !");
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
alert("經緯度定位失敗 !");

else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
alert("參數遺失 !");

else if (gdir.getStatus().code == G_GEO_BAD_KEY)
alert("發生錯誤 !");

else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
alert("資料傳遞錯誤 !");

else alert("發生不知名錯誤 !");

}

function onGDirectionsLoad(){

}

