Issue
I am writing a application that needs to draw a "route" comprised of lots of GPS points (long+lat). The points are close together and don't follow roads, simply drawing a line between each point is ideal.
The current implementation I have is very slow as I am looping over all the GPS coordinates and creating a new Point and overlayitem in an itemized overlay. This takes around 20 seconds for it to load all of these points and draw them to the mapview. Is there a way in which I can construct a series of lines or point from the GPS coordinates and draw them onto the mapview?
Example of current implementation:
for each set of long+lats // removed to simplify
point= new GeoPoint(latitude,longitude);
overlayitem = new OverlayItem(point,"","");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
mMapController.setCenter(point);
Thanks in advance, hope I've explained it well enough.
Solution
Check my reply with code sample here:
How to draw a path on a map using kml file?
This example parses a kml files (xml format as provided by Google Maps or Google Earth for route calculation) and draws the geo points onto the map. If you already have a list of geo points, you can just look at the drawPath() method; and adjust the way you pass the geo coords parameters to it (I encapsulated it into a simple bean that I named NavigationDataSet).
Answered By - Mathias Conradt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.