途经点

html,

body,

#container {

width: 100%;

height: 100%;

}

#panel {

position: fixed;

background-color: white;

max-height: 90%;

overflow-y: auto;

top: 10px;

right: 10px;

width: 280px;

}

#panel .amap-lib-driving {

border-radius: 4px;

overflow: hidden;

}

//基本地图加载

var map = new AMap.Map("container", {

resizeEnable: true,

center: [116.397428, 39.90923],//地图中心点

zoom: 13 //地图显示的缩放级别

});

//构造路线导航类

var driving = new AMap.Driving({

map: map,

panel: "panel"

});

// 根据起终点经纬度规划驾车导航路线

driving.search(new AMap.LngLat(116.379028, 39.865042), new AMap.LngLat(116.427281, 39.903719),{

waypoints:[new AMap.LngLat(116.379028, 39.885042)]

}, function(status, result) {

// result 即是对应的驾车导航信息,相关数据结构文档请参考 https://lbs.amap.com/api/javascript-api/reference/route-search#m_DrivingResult

if (status === 'complete') {

log.success('绘制驾车路线完成')

} else {

log.error('获取驾车数据失败:' + result)

}

});

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐