2013-10-17 50 views
1

现在我正在研究移动应用程序,它以特定间隔获取gps位置,将位置数据发送到服务器。服务器根据此信息绘制Google路线图。绘制谷歌路线图:修复路线中的错误

请帮我解决以下情形

有时GPS坐标标示实际行驶的相反的路线上,使路线完全错误。

例如我走在route like this (On google map)

enter image description here

但我得到map like (On google map)

enter image description here

的点B被取出/标记的平行道路上

我怎么解决这个问题?

+0

移动指向正确的道路?如果你有太多的数据需要手动完成,你需要创建一个算法来检测不正确的点并修复它(这并不容易)。 – geocodezip

+0

@geocodezip你知道任何类似的算法或删除不正确的点的逻辑。 –

+2

如果我这样做,我会指出你。 – geocodezip

回答

0

尝试亚历山大图书馆的路线卓尔

编译 'com.github.jd - 亚历山大:库: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(); 
 

 

 
    }