q2617426
无感五
2017-07-17 04:10

请问下面这段代码单位米如何改为公里

50
  • 百度
  • 91
  • api


输入城市:
输入起点:
输入目的地:



// 百度地图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); }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐