There's no need to decode the encoded polyline; it is already encoded for you.
Each DirectionsStep<http://code.google.com/apis/maps/documentation/v3/reference.html#DirectionsStep> contains an Array of LatLngs, to display the polyline for that step. On Fri, Jan 8, 2010 at 4:11 PM, TTA <[email protected]> wrote: > 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]<google-maps-js-api-v3%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-maps-js-api-v3?hl=en. > > > >--
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.
