2012-01-22 22 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

相关问题