java - 高德地圖平滑移動問題
問題描述
public void startMove() { LatLngBounds.Builder b = LatLngBounds.builder(); for (int i = 0; i < latLngs.size(); i++) {b.include(latLngs.get(i)); } LatLngBounds bounds = b.build(); mAMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100)); // 取軌跡點的第一個點 作為 平滑移動的啟動 LatLng drivePoint = latLngs.get(0); Pair<Integer, LatLng> pair = SpatialRelationUtil.calShortestDistancePoint(latLngs, drivePoint); latLngs.set(pair.first, drivePoint); final List<LatLng> subList = latLngs.subList(pair.first, latLngs.size()); // 設置軌跡點 smoothMarker.setPoints(subList); // 設置平滑移動的總時間 單位 秒 smoothMarker.setTotalDuration(100); // 開始移動 smoothMarker.startSmoothMove(); // 設置移動的監聽事件 返回 距終點的距離 單位 米 smoothMarker.setMoveListener(new SmoothMoveMarker.MoveListener() {@Overridepublic void move(final double distance) {runOnUiThread(new Runnable() {@Overridepublic void run() {} });} });}
// 我這邊需要實現歷史軌跡,并且顯示跑的路線,線已經畫好,這是啟動跑起來的方法。
這邊需要同時顯示速度,速度拿到全部點的速度的集合了,但是無法對應起來。有沒有什么解決方法可以到某個點的時候實時顯示當前的速度的回調或者方法。另求助實時獲取經緯度后如何實時地圖顯示的方法。 高德地圖
問題解答
回答1:在 smoothMarker.setMoveListener 這個監聽中可以 用到getIndex獲取到當前隊列的下標,所以可以根據下標獲取到當前速度并設置
相關文章:
1. docker安裝后出現Cannot connect to the Docker daemon.2. 為什么我ping不通我的docker容器呢???3. android - webview 自定義加載進度條4. mysql - 怎么讓 SELECT 1+null 等于 15. javascript - 微信音樂分享6. 網頁爬蟲 - 用Python3的requests庫模擬登陸Bilibili總是提示驗證碼錯誤怎么辦?7. javascript - 微信小程序封裝定位問題(封裝異步并可能多次請求)8. 并發模型 - python將進程池放在裝飾器里為什么不生效也沒報錯9. linux - openSUSE 上,如何使用 QQ?10. python 怎樣用pickle保存類的實例?
