百度地图获取两点间距离
以下为根据地点名称获取两点之间距离
var map = new BMap.Map("allmap"); // 创建Map实例
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11); // 初始化地图,设置中心点坐标和地图级别
var searchComplete = function (results){
if (transit.getStatus() != BMAP_STATUS_SUCCESS){
return ;
}
var plan = results.getPlan(0);
var distance = plan.getDistance(false)/1000
console.log('距离'+distance.toFixed(2)+'公里')
// alert(distance)
}
var transit = new BMap.DrivingRoute(map, {renderOptions: {map: map},
onSearchComplete: searchComplete
});
transit.search(SendAdd + sendDetail, ReceiveAdd + receiveDetail);