Android Question How to decode points element of google directions api

Ohanian

Active Member
Licensed User
Longtime User
Hi,

i'm trying to show the direction from point A to B on google map.

with this code i manage to get the direction :

B4X:
http://maps.googleapis.com/maps/api/directions/xml?origin=36,52&destination=36.1,52.1&sensor=false&units=metric&mode=driving

the result is something like this :
...
B4X:
<polyline>
<points>
yq_yEwfwxHCJ?Ln@fCLj@FHHFJ@HGBI?Qw@{CpBRvBTPBbCVj@HX@lALj@BD?
</points>
</polyline>
...

it seems that the points are encoded, and i have to decode it to get the latlon to draw on my map.

found this on google :
To use a polyline from the Direction Web service, you need the
google.maps.geometry.encoding.decodePath() function from the geometry
library.

but i don't know how to call this in B4A.

Google also has a service to decode this data :

B4X:
https://developers.google.com/maps/documentation/utilities/polylineutility

is there any solution?

tanx in advance
 

Ohanian

Active Member
Licensed User
Longtime User
Hi,

B4X:
https://developers.google.com/maps/documentation/javascript/geometry

i think it's javascript.

update :
found this :

B4X:
http://grepcode.com/file/repo1.maven.org/maven2/com.github.rwl/gwt-maps/3.8.0-pre1/com/google/maps/gwt/client/geometry/Encoding.java
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
here's a java source code :

B4X:
http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/
 
Upvote 0

Ohanian

Active Member
Licensed User
Longtime User
Hi,

tnx , that's the exact code that i was looking for.
 
Upvote 0
Top