【问题标题】:Draw google road maps : Fixing the error in route绘制谷歌路线图:修复路线错误
【发布时间】:2013-10-25 13:38:05
【问题描述】:

现在我正在开发移动应用程序,该应用程序以特定间隔获取 gps 位置,将位置数据发送到服务器。服务器根据这些信息绘制谷歌路线图。

请帮我解决以下场景

有时,在对面路线上标记的 gps 坐标实际行驶并导致路线完全错误。

例如我乘坐route like this (On google map)

但我得到map like (On google map)

平行道路上获取/标记B点

我该如何解决这个问题?

【问题讨论】:

  • 将点移动到正确的道路上?如果您有太多数据需要手动执行,则需要创建一个算法来检测错误点并进行修复(这并不容易)。
  • @geocodezip 你知道有什么类似的算法或逻辑可以去除不正确的点吗?
  • 如果我这样做了,我会指给你看的。

标签: google-maps gps geocoding


【解决方案1】:

尝试使用 alexander 库来实现路线卓尔

编译'com.github.jd-alexander:library:1.1.0'

示例:

private void startRouting() {

        
        LatLng  origin = new LatLng(18.01455, -77.499333);
        LatLng destination = new LatLng(18.0145600, -77.491333);
        Routing routing = new Routing.Builder()
                .travelMode(Routing.TravelMode.DRIVING)
                .alternativeRoutes(false)
                .withListener(new RoutingListener() {
                    @Override
                    public void onRoutingFailure(RouteException e) {
                        Log.e("onRoutingFailure: ", e.getMessage());
                    }

                    @Override
                    public void onRoutingStart() {

                    }

                    @Override
                    public void onRoutingSuccess(ArrayList<Route> routes, int shortestRouteIndex) {
                        if (routes != null && routes.size() > 0) {
                            for (Route route : routes) {
                                List<LatLng> latlngs = route.getPoints();
                                try {

                                    Random rnd = new Random();
                                    int color = Color.argb(200, rnd.nextInt(256), rnd.nextInt(256), 0);
/*                                    int color1 = Color.argb(225, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
                                    int color2 = Color.argb(225, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
                                    int color3 = Color.argb(225, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));*/
                                    mMap.addPolyline(new PolylineOptions().addAll(latlngs).color(color).width(12.0f));

                                } catch (Exception e) {
                                    e.printStackTrace();
                                    Log.e("onRoutingSuccess: ", e.getMessage());
                                    Toast.makeText(MainActivity.this, "An internal error occurred!", Toast.LENGTH_SHORT).show();
                                }
                            }
                            //showBottomSheet(routes.get(shortestRouteIndex));
                        }
                    }

                    @Override
                    public void onRoutingCancelled() {
                        Log.e("onRoutingCancelled: ", "Routing cancelled");
                    }
                })
                .waypoints(origin, destination)
                .build();
        routing.execute();


    }

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多