Search code examples
androidgoogle-maps-api-2google-polyline

Optimizing polyline on map to have as few points as possible


I`m developing an android app that is tracking the user`s position and at each location update it`s refreshing the polyline representing the user`s journey on the map (V2). The trip can be quite long and I`m saving all of these trips to a local database and later possibly readding them to a map. In order to not overuse memory, I`d like to optimize these polylines so they contain as few LatLngs as possible, e.g. if the user is stuck at a position for a long time, I`m definitely not gonna need all of the LatLngs of that position.

Any tips how I could do that?


Solution

  • In the end I used simplify to do it, with a 1 meter tolerance I got a polyline of 60 points instead of 1000.