0

This is my current map and what I want. We see in blue the current lines drawn, and in red those expected. I want the user's trips to follow the road and not get out. I have no clue on how to proceed. And feel free to give some advice on the user's locations data storage in database to make a " history road taken". Thanks!

     mMap = googleMap;
     ArrayList<LatLng> coordList = new ArrayList<LatLng>();
coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        coordList.add(new LatLng(XXXXXXXX, XXXXXXXX));
        Polyline line = mMap.addPolyline(new PolylineOptions()
                .addAll(coordList)
                .width(10)
                .color(Color.BLUE));
  • You need [Snap on roads API](https://developers.google.com/maps/documentation/roads/snap?hl=en). Take a look at [this](https://stackoverflow.com/q/47329243/6950238) question. If your path didn't have enough points use approach like in [that answer](https://stackoverflow.com/a/49135356/6950238). – Andrii Omelchenko Sep 18 '20 at 12:10
  • @AndriiOmelchenko Thanks! I will implement this method. – GabrielSweb Sep 18 '20 at 17:36

0 Answers0