地图v2中的多段线结束时感到不安 [英] unease at the end of polylines in map v2

查看:85
本文介绍了地图v2中的多段线结束时感到不安的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个地图v2应用程序,可以绘制多段线从精确定位到用户当前位置从GPS获取。



我使用谷歌方向获取折线字符串。



查看每个折线的终点后会有些不安。



查看实际设备的截图:





这是我的绘图代码:
if (allPoints [j]!= null){
System.out.println(pontos+ allPoints [j]);

列表< LatLng> test = decodePoly(allPoints [j]);

for(int i = 0; i< test.size() - 1; i ++){
LatLng src = test.get(i);
LatLng dest = test.get(i + 1);
尝试{

Polygon line = googleMap.addPolygon(new PolygonOptions()
.add(new LatLng(src.latitude,src.longitude),
new LatLng (dest.latitude,dest.longitude))
.strokeColor(Color.BLUE).geodesic(true));

$ b $ catch(NullPointerException e){
Log.e(Error,NullPointerException onPostExecute:+ e.toString());
} catch(Exception e2){
Log.e(Error,Exception onPostExecute:+ e2.toString());
}

}
}

}

可以在每条多段线后放一个圆圈吗?它修复了我的问题吗?

解决方案

正如@Cheesebaron所述,最好的选择是只添加一个 。我没有测试过,因为我没有 allPoints 数据的例子,但它可能是这样的:

  for(int j = 0; j  if(allPoints [j]!= null){
List< LatLng> test = decodePoly(allPoints [j]);
Polyline line = googleMap.addPolyline(new PolylineOptions()。color(Color.BLUE).geodesic(true).addAll(test));




$ b你也可以只创建一个 Polyline 而不是一个 Polyline 为每个 allPoints [j]


$ b

  PolylineOptions polylineOptions = new PolylineOptions()。color(Color.BLUE).geodesic(true); 
for(int j = 0; j if(allPoints [j]!= null){
List< LatLng> test = decodePoly(allPoints [j]);
polylineOptions.addAll(test);
}
}
Polyline line = googleMap.addPolyline(polylineOptions);


i have a map v2 application with ability to drawing polylines from pinpointed location to user current location fetched from gps.

i used google directions in order to get polyline strings.

after drawing got some unease at the end point of each polyline.

see screenshot from actual device :

this is my drawing codes :

for(int j = 0; j < allPoints.length - 1;j++) {

           if(allPoints[j] != null) {
               System.out.println("pontos " + allPoints[j]);

               List<LatLng> test = decodePoly(allPoints[j]);

               for (int i = 0; i < test.size() - 1; i++) {
                   LatLng src = test.get(i);
                   LatLng dest = test.get(i + 1);
                   try {

                       Polygon line = googleMap.addPolygon(new PolygonOptions()
                               .add(new LatLng(src.latitude, src.longitude),
                                       new LatLng(dest.latitude, dest.longitude))
                               .strokeColor(Color.BLUE).geodesic(true));


                   } catch (NullPointerException e) {
                       Log.e("Error", "NullPointerException onPostExecute: " + e.toString());
                   } catch (Exception e2) {
                       Log.e("Error", "Exception onPostExecute: " + e2.toString());
                   }

               }
           }

        }

can i put a circle after each polyline ? does it fix my problem ?

解决方案

As @Cheesebaron states, the best options is adding only one Polyline. I haven't tested it because I don't have an example of your allPoints data, but it could be something like this:

for (int j = 0; j < allPoints.length - 1; j++) {
    if (allPoints[j] != null) {
        List<LatLng> test = decodePoly(allPoints[j]);
        Polyline line = googleMap.addPolyline(new PolylineOptions().color(Color.BLUE).geodesic(true).addAll(test));
    }
}

You can also create only one Polyline instead of one Polyline for each allPoints[j]:

PolylineOptions polylineOptions = new PolylineOptions().color(Color.BLUE).geodesic(true);
for (int j = 0; j < allPoints.length - 1; j++) {
    if (allPoints[j] != null) {
        List<LatLng> test = decodePoly(allPoints[j]);
        polylineOptions.addAll(test);
    }
}
Polyline line = googleMap.addPolyline(polylineOptions);

这篇关于地图v2中的多段线结束时感到不安的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆