Hey Moust,
The polyline is an encoded object in gmap v3 Direction Response. It
has a pile of latlngs which you will get after decoding it. Check this
out http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/decode.html
which provides an awesome example to decode polyline.
The function for decoder is given below
----------------------------------------------------------------
function decodeLine (encoded)
{
var len = encoded.length;
var index = 0;
var array = [];
var lat = 0;
var lng = 0;
while (index < len)
{
var b;
var shift = 0;
var result = 0;
do
{
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
}while (b >= 0x20);
var dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do
{
b = encoded.charCodeAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
}while (b >= 0x20);
var dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));
lng += dlng;
array.push([lat * 1e-5, lng * 1e-5]);
}
return array;
}
is this helpful?
-Many Thanks
TTA
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.