2011-07-27 30 views
0

我想反向地理編碼,我有三個座標,我想將它們轉換爲地址,我已經使用了以下方法。我在執行反向地理編碼時做錯了什麼

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 

     }; 

但它從不顯示任何東西。

我是否正確,在google APIv3中我們可以使用地址字符串或latlng中的一個字符。我們如何在航點使用latlag。

+0

您輸入座標以獲取地址,然後將地址輸入探路者,當探路者未輸出時,您確定地址未正確提供?你有沒有嘗試*測試*給出的地址? – bdares

+0

@bdares其實我不知道如何給google提供的這個waypoint功能,我知道我們也可以給waypoint功能地址。例如' – Sara

+0

例如航點:[{location:london},{location:sussex},{location:manchester}],但我只是不確定lat和lng如何在航點提供。 – Sara

回答

0

你在這裏顯示你的整個代碼? 請發送您的latLng1值,例如。 另外,顯示您的directionsService電話。我這樣做:

directionsService.route(request, function(response, status) { 
     if (status == google.maps.DirectionsStatus.OK) { 
      directionsDisplay.setDirections(response); 
     } else alert(status); 
    }); 

在任何情況下 - 嘗試做alert()您的請求狀態,方向可能不適用於這些點。

順便說一下,您不需要將您的座標反向地址解析到地址以獲取路線。你可以在航點使用座標,這就是你在這裏做的。