android-------高德地圖兩點路線和多個點路線繪制


最近朋友需要兩點路線和多個點路線繪制這個功能,幫忙弄了一下,寫這篇博客與大家分享一下。

兩點路線

是起點和終點兩個經緯度點,高德繪制出路線,可以實現實線和虛線功能

效果圖:

      

 

相關屬性:

 

        mPolylineOptions = new PolylineOptions();
        mPolylineOptions.setDottedLine(true);//設置是否為虛線
        mPolylineOptions.geodesic(false);//是否為大地曲線
        mPolylineOptions.visible(true);//線段是否可見
        mPolylineOptions.useGradient(false);//設置線段是否使用漸變色
        //設置線顏色,寬度
        mPolylineOptions.color(getWalkColor()).width(getRouteWidth());

 

 

 

 

 

多點路線

這個可以用來記錄行走軌跡,無數個坐標點繪制路線

效果圖:(我測了10個點)

  

 

 

相關代碼:

 

        //起點位置和  地圖界面大小控制
        aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(list.get(0), 7));
        aMap.setMapTextZIndex(2);
        aMap.addPolyline((new PolylineOptions())
                //手動數據測試
                //.add(new LatLng(26.57, 106.71),new LatLng(26.14,105.55),new LatLng(26.58, 104.82), new LatLng(30.67, 104.06))
                //集合數據
                .addAll(list)
                //線的寬度
                .width(10).setDottedLine(true).geodesic(true)
                //顏色
                .color(Color.argb(255,255,20,147)));

 

 

 

 

 

源碼地址下載:https://github.com/DickyQie/android-gaode-map

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM