【问题标题】:Add Polylines From An Array With A Space从带有空格的数组中添加折线
【发布时间】:2014-08-30 12:25:50
【问题描述】:

我创建了这个循环,在谷歌地图 v2 上绘制我需要的折线。 每个循环它应该在两个标记之间绘制一条折线。 但问题是它连接在新折线和最后一条折线之间。 我怎样才能删除这个“折线连接器”?

这是我的代码:

for(int i=0;i<cons;i++){


                int a=i+1;
                   int b=i+2;
                   int c=i+3;
                   String k0=prefs.getString("cons"+i, "defValue");
                   String k1=prefs.getString("cons"+a, "defValue");
                   String k2=prefs.getString("cons"+b, "defValue");
                   String k3=prefs.getString("cons"+c, "defValue");

                   LatLng constpoint= new LatLng(Double.parseDouble(k0),Double.parseDouble(k1));

                   markerOptions.position(constpoint);                 
                googleMap.addMarker(markerOptions);

                LatLng constpoint2=new LatLng(Double.parseDouble(k2),Double.parseDouble(k3));
                 markerOptions.position(constpoint2);                  
                    googleMap.addMarker(markerOptions);


                       // Adding the polyline to the map
                      // googleMap.addPolyline(polylineOptions);
                       line2= googleMap.addPolyline(polylineOptions
                          .add(constpoint,
                                 constpoint2));

                       i=i+3;
               }    

【问题讨论】:

    标签: android


    【解决方案1】:

    问题解决了。

    每次启动循环时,只需像这样创建一个新的 PolylineOptions:

     line2= googleMap.addPolyline(new PolylineOptions()
                              .add(constpoint,
                                     constpoint2));
    

    【讨论】:

      猜你喜欢
      • 2021-09-29
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-04
      • 2018-07-27
      • 1970-01-01
      相关资源
      最近更新 更多