0

I am creating a Android application to that stores location of device at fixed interval of time to a file. The locations make a path as the device goes from one location to other. But I want this path to be displayed in google maps.

Currently I am writing to a text file, i've seen GPX format too, should I write a GPX file, but then how to fetch this file to google maps, is there any API available ?

I am using https://github.com/commonsguy/cwac-locpoll/ in this there is a demo project on which I am relying.

Files : - https://github.com/commonsguy/cwac-locpoll/blob/master/demo/src/com/commonsware/cwac/locpoll/demo/LocationReceiver.java and LocationPollerDemo.java which is Activity class in the same folder

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
fz8975
  • 45
  • 1
  • 8

1 Answers1

0

Maps V2 has no built-in ability to convert any sort of file into a Polyline or similar route. Hence, store it in whatever will be convenient for you to create the Polyline yourself.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Then I should store the locations in a Polyline object then display the route on Map using Overlay, but how do I store coordinates on a object, and when logging stops how to retrieve it ? – fz8975 Mar 03 '13 at 19:15
  • @fz8975: "Then I should store the locations in a Polyline object" -- that is not possible. What you are presently doing ("I am writing to a text file") is perfectly fine. – CommonsWare Mar 03 '13 at 20:07
  • ok..but how do I show the path. In browser ? or in Google Maps – fz8975 Mar 04 '13 at 02:07
  • How to show the path using coordinates in the file ?? Help ..! – fz8975 Mar 04 '13 at 16:36
  • @fz8975: Use a `Polyline` to *display* the path. Use a file or database to *save* the path. – CommonsWare Mar 04 '13 at 16:45
  • I downloaded Google Play services for google maps api but it does not contain Polyline class...any idea what could be the problem ?? – fz8975 Mar 05 '13 at 16:28
  • @fz8975: "I downloaded Google Play services for google maps api but it does not contain Polyline class" -- yes, it does. I use it here: https://github.com/commonsguy/cw-omnibus/tree/master/MapsV2/Poly – CommonsWare Mar 05 '13 at 17:00
  • ok thats solved but I have a new problem now..`LocationReceiver` writes location in `Location` class object but in `Polyline` I can only add `Latlng`...?? – fz8975 Mar 05 '13 at 18:02
  • @fz8975: Grab the latitude and longitude out of the `Location` object and create a `LatLng` object containing those values. Please do not comment further on this answer. If you have additional questions, use the "Ask Question" link in the upper-right corner of this page. – CommonsWare Mar 06 '13 at 14:21
  • One Last question How do I get the current Latitude and Longtitude in the Main Activity ? I want to display it in `TextView` – fz8975 Mar 17 '13 at 16:26