输入城市:
输入起点:
输入目的地:
// 百度地图API功能 var map = new BMap.Map("allmap"); map.centerAndZoom(new BMap.Point(116.404, 39.915), 12); var searchComplete = function (results) { if (transit.getStatus() != BMAP_STATUS_SUCCESS) { return; } var plan = results.getPlan(0); var output = "从" + document.getElementById('txtCity').value + "到" + document.getElementById('txtPoint').value + "驾车需要"; output += plan.getDuration(true) + "<br>"; output += "总路程为:"; output += plan.getDistance(true) + "<br>"; document.getElementById('info').innerHTML = output }; var transit = new BMap.DrivingRoute(map, { renderOptions: { map: map }, onSearchComplete: searchComplete, onPolylinesSet: function () { // setTimeout(function () { alert(output) }, "1000"); } }); function doSearch() { var txtCity = document.getElementById('txtCity'), txtPoint = document.getElementById('txtPoint') if (txtCity.value != '' && txtPoint.value != '') transit.search(txtCity.value, txtPoint.value); }