日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java 高德地图路线规划_高德地图api之路线规划

發布時間:2023/12/14 编程问答 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 高德地图路线规划_高德地图api之路线规划 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.引入

2.創建并初始化實例對象

const map = new AMap.Map("container")

3.創建一個導航元素,用來承載導航路線(這里不要忘了,是個坑,用的啥時候踩過,文檔里沒有詳細說)

4.使用路線規劃插件

這里先拿駕車路線規劃舉個例子

假設var start = "天安門", end = "人民大會堂"

AMap.plugin('AMap.Driving', function () {

const driving = new AMap.Driving({

// 駕車路線規劃策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式

policy: AMap.DrivingPolicy.LEAST_TIME,

// map 指定將路線規劃方案繪制到對應的AMap.Map對象上

map: map,

// panel 指定將結構化的路線詳情數據顯示的對應的DOM上,傳入值需是DOM的ID

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

// 搜索完成后,將自動繪制路線到地圖上

driving.search(points)

})

當然不只有駕車路線規劃,還有其他類型:

步行規劃

AMap.plugin('AMap.Walking', function () {

const walking = new AMap.Walking({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

walking.search(points)

})

騎行規劃

AMap.plugin('AMap.Riding', function () {

const riding = new AMap.Riding({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

riding.search(points)

})

公交規劃

AMap.plugin('AMap.Transfer', function () {

const transfer = new AMap.Transfer({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

transfer.search(points)

})

貨車規劃(一天只能調用100次,超過收費)

AMap.plugin('AMap.TruckDriving', function () {

const truckDriving = new AMap.TruckDriving({

map: map,

panel: 'panel',

// policy: ,

size: 1, // 必填, 車輛大小

})

const points = [

{ keyword: start },

{ keyword: end }

]

truckDriving.search(points)

})

以上只是簡單的實現,具體的屬性和方法還是要看文檔的

附demo:

Document

起始點:

目的地:

步行規劃

騎行規劃

駕車規劃

公交規劃

貨車規劃

const map = new AMap.Map('container')

function gui(tab) {

const start = document.getElementById('start').value

const end = document.getElementById('end').value

switch (tab) {

case 1:

walking(start, end)

break;

case 2:

riding(start, end)

break;

case 3:

driving(start, end)

break;

case 4:

transfer(start, end)

break;

case 5:

truckDriving(start, end)

break;

}

}

// 步行規劃

function walking(start, end) {

AMap.plugin('AMap.Walking', function () {

const walking = new AMap.Walking({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

walking.search(points)

})

}

// 騎行規劃

function riding(start, end) {

AMap.plugin('AMap.Riding', function () {

const riding = new AMap.Riding({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

riding.search(points)

})

}

// 駕車規劃

function driving(start, end) {

AMap.plugin('AMap.Driving', function () {

const driving = new AMap.Driving({

// 駕車路線規劃策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式

policy: AMap.DrivingPolicy.LEAST_TIME,

// map 指定將路線規劃方案繪制到對應的AMap.Map對象上

map: map,

// panel 指定將結構化的路線詳情數據顯示的對應的DOM上,傳入值需是DOM的ID

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

// 搜索完成后,將自動繪制路線到地圖上

driving.search(points)

})

}

// 公交規劃

function transfer(start, end) {

AMap.plugin('AMap.Transfer', function () {

const transfer = new AMap.Transfer({

map: map,

panel: 'panel'

})

const points = [

{ keyword: start },

{ keyword: end }

]

transfer.search(points)

})

}

// 貨車路徑規劃

function truckDriving(start, end) {

AMap.plugin('AMap.TruckDriving', function () {

const truckDriving = new AMap.TruckDriving({

map: map,

panel: 'panel',

// policy: ,

size: 1, // 必填, 車輛大小

})

const points = [

{ keyword: start },

{ keyword: end }

]

truckDriving.search(points)

})

}

總結

以上是生活随笔為你收集整理的java 高德地图路线规划_高德地图api之路线规划的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。