lundi 29 décembre 2014

Getting geolocation for route direction for Google API


I have used first function to get user's geolocation and other function named calcRoute to get the route of the user from its geolocation to the destination. But the routing part is not working when I am trying to get directions from the geolocation to a destination.



`function initialize() {if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) {var latitude =position.coords.latitude; var longitude = position.coords.longitude; var latlng = new google.maps.LatLng(latitude, longitude); directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false
};function calcRoute(data) {
var start = document.getElementById("routeStart").value;
var end = new google.maps.LatLng(data.coords.latitude,data.coords.longitude);
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};`




Aucun commentaire:

Enregistrer un commentaire