use*_*388 2 android android-maps-v2
如何在谷歌地图中绘制多个纬度和经度坐标的折线.我需要动态绘制至少20组纬度和经度的折线.
使用折线和arraylist在地图中添加多个点
ArrayList<LatLng> coordList = new ArrayList<LatLng>();
// Adding points to ArrayList
coordList.add(new LatLng(0, 0);
coordList.add(new LatLng(1, 1);
coordList.add(new LatLng(2, 2);
// etc...
// Find map fragment. This line work only with support library
GoogleMap gMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
PolylineOptions polylineOptions = new PolylineOptions();
// Create polyline options with existing LatLng ArrayList
polylineOptions.addAll(coordList);
polylineOptions
.width(5)
.color(Color.RED);
// Adding multiple points in map using polyline and arraylist
gMap.addPolyline(polylineOptions);
Run Code Online (Sandbox Code Playgroud)
Android文档中的示例:
GoogleMap map;
// ... get a map.
// Add a thin red line from London to New York.
Polyline line = map.addPolyline(new PolylineOptions()
.add(new LatLng(51.5, -0.1), new LatLng(40.7, -74.0))
.width(5)
.color(Color.RED));
Run Code Online (Sandbox Code Playgroud)
只要.add你需要多次打电话.
| 归档时间: |
|
| 查看次数: |
13244 次 |
| 最近记录: |