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

Load the V3 API with:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?
libraries=geometry&amp;sensor=false">
</script>



Create the map, set markers for start and destination and so on.

Replace backslashes '\'  in points with '\\', it seems the levels are
kinda ballast from V2 (?).

var encodedPoints   = "s}dcFlnchVz@n@vJeVpF}NzMy\\}
KyI{AoBg@{@wKmWs@wB_AsE_@wEQkLQ}Cy@qE{@kCiBsD{_@_r@qS{\
\mBqDoOw^mBwGOqAPyEGsAKu@eBmEOu@Eu@X}DEu@r_@osCjJyi@|
AiH~B_NxJoe@j[kdBjLwl@rJkh@zG_]jCsOhEe\\`Iur@pBuOjAuLhAsI|
BcPnCuNhAiEz@_B~@kA|
AgAnLcDvBmAt@o@dBwBxEwJtI_PzBcDdE_EnVePpg@o]lKsFzJgE`EkCjCqCrB{CvAwCtBmFfAsB`DiEdC_CpEkClGgC`EyBrG_ETAdHuDx@YdAKhEb@jB]hAi@{EaOmDqJeEnC"
 ;

var decodedPoints =
google.maps.geometry.encoding.decodePath(encodedPoints) ;

var encodedPolyline = new google.maps.Polyline ( {
              strokeColor: "#970E04" ,
              strokeOpacity: 1.0 ,
              strokeWeight: 2 ,
              path: decodedPoints ,
              clickable: false
} );
encodedPolyline.setMap(myMap);

Done.

HTH
Sebastian


On Dec 15 2010, 5:24 am, Christian Zambrano <[email protected]>
wrote:
> The response of a request for direction to the Google Maps Web Service
> includes encoded polylines in the element overview_polyline. I would like to
> display these polylines on a Javascript google map V3 but there doesn't seem
> to be a way. Am I missing something? V2 had GPolyline which accepted encoded
> Polylines.
>
> Any help would be greatly appreciated.

-- 
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.

Reply via email to