I am trying reverse geocoding, I have three coordinates and I want to convert them to addresses, I have used following method.
var point1 = new google.maps.LatLng(latLng1);
var point2 = new google.maps.LatLng(latLng2);
var point3 = new google.maps.LatLng(latLng3);
where latLng1, latLng2, latLng3 are coordinates.
and then further I want to use these addresses to following code to create a path
var request = {
origin:location1,
destination:location2,
waypoints:[{location: point1}, {location: point2}, {location: point3}],
travelMode: google.maps.DirectionsTravelMode.WALKING
};
but it never displays anything.
Am I doing it right, One more thi开发者_StackOverflowng it says in google APIv3 that we can either use string of address in waypoint or latlng. how we can use latlag in waypoint.
Are you showing your whole code here? Please, post your latLng1 value, for example. Also, show your directionsService call. I do like that:
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else alert(status);
});
In any case - try do alert() your request statuses, directions may not be available for these points.
By the way you don't need to reverse geocode your coordinates to addresses to get directions. You can use coordinates in waypoints, which is what you doing here.
精彩评论