2012-01-22 61 views
0

我與使用者GeoCode檢測的路線&之間存在衝突。如何製作Google Maps V3路線使用用戶位置檢測 - GeoCoder

如果我這樣做:

var MapCenter = new google.maps.LatLng(-33.8665433, 151.1956316); 

function initialize(lat,lng) { 

geocoder = new google.maps.Geocoder(); 
// var MapCenter = new google.maps.LatLng(lat,lng); 
geocodeThis(MapCenter); 

方向做工精細,但地理編碼器並沒有得到用戶的位置。

如果我不喜歡這樣寫道:

// var MapCenter = new google.maps.LatLng(-33.8665433, 151.1956316); 

function initialize(lat,lng) { 

geocoder = new google.maps.Geocoder(); 
var MapCenter = new google.maps.LatLng(lat,lng); 
geocodeThis(MapCenter); 

地理編碼器獲取用戶的位置,但是當你點擊信息窗口,然後在方向上,該腳本不會做任何事情。相反,它應該爲您提供從當前(僅GeoCoded)位置到該標記的路線。

這是我的full code

+2

不要把「尚未解決」的標題。只要沒有被接受的答案,我們知道它沒有解決。 – simchona

+1

「不起作用」不是問題描述。 –

+0

我改寫了這個問題,@Lightness在軌道競賽 – Sebastian

回答

0

你應該用不同的名稱調用變量。他們都稱爲「MapCenter」,當然他們衝突...

你想達到什麼目的?

+0

嗨,Satoshi,他們需要是同一個名字,因爲他們是中心。我嘗試獲取用戶的位置,然後根據該位置將地圖居中。在第二個例子中有效。但是當我打開一個InfoWindow,然後在「Directions」中,指示不起作用,這在第一個示例中起作用。 @satoshi – Sebastian

相關問題