谷歌地图android studio不显示我的折线

时间:2016-02-11 01:46:15

标签: android google-maps android-studio google-polyline

我不知道为什么这条折线不会显示,我已经把谷歌地图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);

1 个答案:

答案 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