2010-10-24 100 views
1

GeocoderRequest對象中有「location」屬性,它定義了「LatLng關於要搜索的內容。可選。」,但我試圖使用它,但這是行不通的:Google Maps API v3 Geocoder.geocode()參數「location」不起作用

geocoder.geocode({ address: control.value, location: new google.maps.LatLng(59.938531, 30.313497)}, function(results, status) {....})

例如,當我在59.938531,30.313497尋找一些地址,所以results包含2個對象,正確的地址具有指數[1]但不[0]

回答

1

該位置無效。你想要地址或latLng。該GeocodeRequest對象常量包含以下字段:

{ 
address: string, 
latLng: LatLng, 
bounds: LatLngBounds, 
language: string, 
region: string 
} 
+0

爲什麼「位置」屬性是無效的?檢查http://code.google.com/intl/ru-RU/apis/maps/documentation/javascript/reference.html#GeocoderRequest - 「location」屬性的描述 – barbushin 2010-10-30 04:37:34

+0

它看起來像文檔中的錯誤。爲什麼你想同時使用地址和位置? 如果你使用地址,你會做一個地理編碼來獲取latLng,如果你使用latLng,那麼你會做一個反向地理編碼來獲取地址。 – skarE 2010-11-01 20:33:43