我不知道为什么这条折线不会显示,我已经把谷歌地图api和启用了方向api
PolylineOptions rectOptions = new PolylineOptions();
rectOptions.add(new LatLng(24.009115, -104.699933));
rectOptions.add(new LatLng(24.009115, -104.699933));
rectOptions.width(5);
rectOptions.color(Color.RED);
Polyline polyline = mMap.addPolyline(rectOptions);
答案 0 :(得分:2)
Add()
,width()
和color()
都会返回PolylineOptions
并添加新设置。
PolylineOptions rectOptions = new PolylineOptions();
rectOptions =rectOptions.add(new LatLng(24.009115, -104.699933));
rectOptions =rectOptions.add(new LatLng(24.009115, -104.699933));
rectOptions =rectOptions.width(5);
rectOptions =rectOptions.color(Color.RED);
Polyline polyline = mMap.addPolyline(rectOptions);
或
PolylineOptions rectOptions = new PolylineOptions()
.add(new LatLng(24.009115,-104.699933),
new latlang(24.009115,-104.699933))
.width(5)
.color(Color.red);
Polyline polyline = mMap.addPolyline(rectOptions);
来源:https://developers.google.com/android/reference/com/google/android/gms/maps/model/PolylineOptions