Skip to content Skip to sidebar Skip to footer

How To Display A Moving Track On Android Device

I want to plot my track using GPS on an Android device. I have no problem displaying a completed route but am finding it difficult to show the track as I'm moving. So far, I've fou

Solution 1:

There's a straightforward solution using the 2.0 Maps API. You'll get a nice smooth route line using three steps:

  1. create a list of LatLng points such as:

    List<LatLng> routePoints;
    
  2. Add the route points to the list (could/should be done in a loop):

    routePoints.add(mapPoint);
    
  3. Create a Polyline and feed it the list of LatLng points as such:

    Polyline route = map.addPolyline(new PolylineOptions()
      .width(_strokeWidth)
      .color(_pathColor)
      .geodesic(true)
      .zIndex(z));
    route.setPoints(routePoints);
    

Give it a try!

Post a Comment for "How To Display A Moving Track On Android Device"