ald*_*to2 4 android google-maps dynamically-generated google-polyline
我有一个
places = ArrayList<ArrayList<LatLng>>
Run Code Online (Sandbox Code Playgroud)
我将LatLng点添加到内部ArrayList中,然后我有一个for循环,循环并向地图添加折线......除了它不这样做...如何动态地将折线添加到GoogleMap?我检查了地方是否被填充,它是.
提前致谢.
ArrayList<Polyline> pl = new ArrayList<Polyline>();
for(int i =0; i<places.size(); i++){
pl.add(mMap.addPolyline(new PolylineOptions().addAll(places.get(i))));
Log.e("size of places", "size of places is " + places.size());
}
Run Code Online (Sandbox Code Playgroud)
use*_*968 13
使用折线和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)
一旦列表中有经度纬度列表,就可以使用下面的线条绘制线条.
List<LatLng> points = decodePoly(_path); // list of latlng
for (int i = 0; i < points.size() - 1; i++) {
LatLng src = points.get(i);
LatLng dest = points.get(i + 1);
// mMap is the Map Object
Polyline line = mMap.addPolyline(
new PolylineOptions().add(
new LatLng(src.latitude, src.longitude),
new LatLng(dest.latitude,dest.longitude)
).width(2).color(Color.BLUE).geodesic(true)
);
}
Run Code Online (Sandbox Code Playgroud)
以上在我的申请中为我工作
| 归档时间: |
|
| 查看次数: |
17851 次 |
| 最近记录: |