I'm making an android app that maps my path through plotting polylines using the google map API. If I have several of these paths, it just looks like a bunch of paths plotted on top of each other. Is there a way, through the Google Maps API to "average" these paths out? I was starting to head down a complicated path of computing the headings (geography util) and using those headings to get nearby polylines with similar headings and then averaging out the lats and lons to draw a polyline that was the average of all of the similar polylines. Before I do that I was wondering if anyone knew of a better way and/or if I should be using polygons instead of polylines? Here's a visual of what I am trying to do (sorry I used paint):
[GIS] Android Google Maps average polyline paths
androidgoogle mapsjava
Best Answer
I don't know of a function in the googlemap api which would do what you want but I would do it kinda like below. I know that there are of course better ways of doing this but it is a simple way and you don't need the whole heading and bearing calculations.
You have to use the
GoogleMap.getProjection().getProjection().toScreenLocation(LatLng)
on every visible LatLng Point.This checks if every point in pointlist1 is within a square of a point from pointlist2 independent where the Polyline startet or which directions they went. If your Points are to close together think about a path simplification algorithm like the Ramer–Douglas–Peucker algorithm.