//1.创建一个经纬度数组
LatLng pt1 = new LatLng(list.get(i). lat, list.get(i). lng);
protected void drawMyRoute(List<LatLng> points2) {
//添加纹理图片
List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>();
BitmapDescriptor mRedTexture = BitmapDescriptorFactory
.fromAsset("icon_road_red_arrow.png");//箭头图片
textureList.add(mRedTexture);
// 添加纹理图片对应的顺序
List<Integer> textureIndexs = new ArrayList<Integer>();
for (int i=0;i<points2.size();i++){
textureIndexs.add(0);
}
OverlayOptions options = new PolylineOptions()
.textureIndex(textureIndexs)//设置分段纹理index数组
.customTextureList(textureList)//设置线段的纹理,建议纹理资源长宽均为2的n次方
.dottedLine(true)
.color(0xAAFF0000)
.width(15)
.points(points2);
mBaiduMap.addOverlay(options);
List<LatLng> latLngPolygon = new ArrayList<LatLng>();
//2.这是一组经纬度集合(数据自己找)LatLng pt1 = new LatLng(list.get(i). lat, list.get(i). lng);
latLngPolygon.add(pt1);//经纬度添加到数组里面
//3.到你要用的方法调用画轨迹方法drawMyRoute(latLngPolygon);
//4.画轨迹方法protected void drawMyRoute(List<LatLng> points2) {
//添加纹理图片
List<BitmapDescriptor> textureList = new ArrayList<BitmapDescriptor>();
BitmapDescriptor mRedTexture = BitmapDescriptorFactory
.fromAsset("icon_road_red_arrow.png");//箭头图片
textureList.add(mRedTexture);
// 添加纹理图片对应的顺序
List<Integer> textureIndexs = new ArrayList<Integer>();
for (int i=0;i<points2.size();i++){
textureIndexs.add(0);
}
OverlayOptions options = new PolylineOptions()
.textureIndex(textureIndexs)//设置分段纹理index数组
.customTextureList(textureList)//设置线段的纹理,建议纹理资源长宽均为2的n次方
.dottedLine(true)
.color(0xAAFF0000)
.width(15)
.points(points2);
mBaiduMap.addOverlay(options);
}
//5.箭头图片自己下载放到assets文件夹里面
//6.效果图片