Try draw path with google direction

المشرف العام

Administrator
طاقم الإدارة
I have make a Web-application , The user choose from a list Point of interested and click submit and these point of interested is saw in the map , so far is warking if i try to make a path from user position and the point of interested that is click i cant do it , i try to use the Google Mpas Direction Api , in request of Google direction i put the coords of user position and the coords of the clicked point of interested . i put an alert on the click listener and show the coords of user and the coords of point of inderest , but when i send it as a request in the google direction nothing came back, i cant find what is wrong

Heare is the click event and the method i use for get direction for draw the path from user to interest point which chose.

google.maps.event.addListener(marker, 'click', function() { var latitude = this.position.lat(); var longitude = this.position.lng(); getCoords(latitude,longitude); } );function getCoords(latitude,longitude) { var start = latitude+","+longitude; var end = latPos+","+longPos; /* var start = new google.maps.LatLng(latitude,longitude); var end = new google.maps.LatLng(latPos,longPos); */ alert(start+" "+end); var request = { origin: start, destination: end, provideRouteAlternatives: false, }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); alert(JSON.parse(response.responseText)); steps(response); createPolyline(response); } }); }

أكثر...
 
أعلى