Here you go. Pass it through stringWithFormat with doubled lat long duration and after the final lat long, all of them are like float:
[NSString stringWithformat: ..., oriLat, oriLon, oriLat, oriLon, destLat, destLon];
and then pass it to UIWebView
<html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> <script type="text/javascript"> var directionsDisplay = new google.maps.DirectionsRenderer(); var directionsService = new google.maps.DirectionsService(); function initialize() { var latlng = new google.maps.LatLng(%f, %f); var myOptions = { zoom: 15, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); directionsDisplay.setMap(map); calcRoute(); } function calcRoute() { var start = new google.maps.LatLng(%f, %f); var end = new google.maps.LatLng(%f, %f); var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(result, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(result); } }); } </script> </head> <body onload="initialize()"> <div id="map_canvas" style="width:300px; height:300px"> </body> </html>
source share