loadFromWayPoints() は、提供された入力が地球上の特定の点にマップされている場合にのみ、ポリラインを描画します。出発点を住所ではなく緯度と経度の形式で固定することで、混乱を避けることができます。次に、次の関数を使用して、toInput に対して複数のポイントが返された場合に To ポイントを意味するかどうかを作成できます。
コードは自明です。あなたが理解していない場合。コメントで返信します。プロットするポイントの 1 つは、Google ジオコーダ システムから明確なポイントを返す必要があります。私の場合、始点を定点として使用しました。そして、それを私と調整してもらいました。だから受かる可能性はない
geo.getLocations(toInput, function (result){
//map.clearOverlays();
if (result.Status.code == G_GEO_SUCCESS) {
// ===== If there was more than one result, "ask did you mean" on them all =====
if (result.Placemark.length > 1) {
document.getElementById("textualdirectionscontainer").innerHTML = "Did you mean:";
// Loop through the results
for (var i=0; i<result.Placemark.length; i++) {
var p = result.Placemark[i].Point.coordinates;
document.getElementById("textualdirectionscontainer").innerHTML += "<br>"+(i+1)+": <a href='javascript:place(" +p[1]+","+p[0]+")'>"+ result.Placemark[i].address+"<\/a>";
}
}
// ===== If there was a single marker =====
else {
document.getElementById("textualdirectionscontainer").innerHTML = "";
var p = result.Placemark[0].Point.coordinates;
toLatLang = new GLatLng(p[1], p[0]);
// place(p[1],p[0]);
directionsPanel = $('textualdirectionscontainer');
directionsPanel.getElements('div').each(function(item) {
item.dispose();
});
directions.clear();
directions.loadFromWaypoints([hotelLatLng.toString(), toLatLang.toString()], {getPolyline:true});
/*var gp = directions.getPolyline();
map.addOverlay(gp); */
}
}
});