Possible Duplicate:
Google Maps output=kml broken?
I started to get Error when I’m trying to retrieve Google Directions using KML data since few days. The Error seems that the URL I’m requesting doesn’t retreieve KML data anymore, it returns a whole page. I followed this in order to achieve that.
What is the solution for this? Is there any alternatives?
Update:
Since Android Google Maps v2 is now used, the code needs to be adjusted to work on v2 maps which can be found here.
Original Answer:
This way of extracting the Google Directions from Google by parsing the KML file is no longer available since 27 July 2012 (because Google has changed the structure of retrieving Google Directions, now you can only get it by JSON or XML), it is time to migrate your code to JSON instead of KML.
I did it by creating 6 classes like this:
Parser.java:
XMLParser.java:
Segment.java:
Route.java:
GoogleParser.java:
RouteOverlay.java:
And then you do this inside the Activity that includes the Map:
1-Add this function:
2- Add this in
onCreate()function:EDIT: If you get an exception, please use
directions()function in anAsyncTaskto avoid network processing on the UI thread.