简体   繁体   English

从带有空格的数组中添加折线

[英]Add Polylines From An Array With A Space

I've created this loop that draw the polylines that i need on google maps v2. 我创建了此循环,以绘制在Google Maps v2上需要的折线。 Every loop it should draw one polyline between two markers. 每个循环都应在两个标记之间绘制一条折线。 But the problem is that it connect between the new polyline and the last polyline . 但是问题在于它在新折线和最后一条折线之间连接。 how can i remove this "Polyline connector" ? 如何删除此“多线连接器”?

This is my code: 这是我的代码:

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;
               }    

Problem solved. 问题解决了。

Every time you start the loop just create a new PolylineOptions like this: 每次启动循环时,只需创建一个新的PolylineOptions,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM