【问题标题】:Remove traversed portion of an android google-maps polyline删除 android google-maps 折线的遍历部分
【发布时间】:2018-07-02 08:01:44
【问题描述】:

我想在遍历绘制的折线时删除它的一部分,有点像GPS。我目前正在通过:onLocationChangedLocationListener 接口获取位置更新。

我从 google-directions 请求中绘制了我的折线。它现在的行为类似于GPS,如果您偏离道路,它将再次请求绘制正确的折线:

if (!PolyUtil.isLocationOnPath(mLatLng,polylines.get(index).polyline.getPoints(), true, 20)) {
    //remove it
    //add a new polyline
}

我设法通过在每次位置更改时发出方向请求来重绘折线。然而,这不是一个合适的方法,因为它会产生太多的请求。

有什么方法可以去除折线的某一部分?

谢谢。

【问题讨论】:

    标签: android google-maps google-polyline


    【解决方案1】:

    是的:您可以获取折线的点,删除点并将点设置为折线:

    List<LatLng> polylinePoints = polylines.get(index).polyline.getPoints();
    polylinePoints.remove([INDEX_OF_POINT_TO_REMOVE_1]);
    polylinePoints.remove([INDEX_OF_POINT_TO_REMOVE_2]);
    ...
    polylines.get(index).polyline.setPoints(polylinePoints);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-19
      • 2012-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      • 2014-02-07
      相关资源
      最近更新 更多