【发布时间】:2015-04-06 06:13:37
【问题描述】:
我正在获取 LatLng 值并将所有这些 latlng 放入 arraylist(points),当我调试代码时,我可以看到 latlng 点正在进入 arraylist,但我没有在地图上获得折线。先感谢您。
private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getExtras() != null ) {
points=new ArrayList<LatLng>();
Lat=bundle.getDouble("latitude", 0d);
Lng=bundle.getDouble("longitude", 0d);
Toast.makeText(getApplicationContext(),""+Lat+","+Lng,Toast.LENGTH_SHORT).show();
point = new LatLng(Lat,Lng);
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.color(Color.BLUE);
polylineOptions.width(8);
points.add(point);
polylineOptions.addAll(points);
googleMap.addPolyline(polylineOptions);
}
}
};
【问题讨论】:
-
你会改变 polylineOptions.addAll(points);用for循环试试? for(int i=0;i
-
我猜你是在循环中执行这段代码,你在点数组列表中添加点,所以只需将最后两行移出循环,你就会在地图中绘制所有折线。最后两行` polylineOptions.addAll(points); googleMap.addPolyline(polylineOptions);`
-
@Clairvoyant - 我将那两条线放在循环之外,但我也没有得到折线。
-
@RagamaiK - 你能发布你的完整代码以正确的方式帮助你,而不是猜测和回答你。