Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Google Maps API V3 Places库无法读取属性';地点';未定义的_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript Google Maps API V3 Places库无法读取属性';地点';未定义的

Javascript Google Maps API V3 Places库无法读取属性';地点';未定义的,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,所以我在Chrome中使用Google Maps API V3,并尝试使用Place库向我的地图添加感兴趣的点。除了在setMarker方法中,我从以下行获得一个错误位置:place.geometry.location,错误无法读取未定义的属性“location” 您正在使用setMarker()函数从传递整个结果对象的Places回调中创建标记。但是将LatLng对象传递给执行setMarker(fim)操作的同一个函数 不使用相同的功能,您只需执行以下操作: new google.m

所以我在Chrome中使用Google Maps API V3,并尝试使用Place库向我的地图添加感兴趣的点。除了在setMarker方法中,我从以下行获得一个错误
位置:place.geometry.location
,错误
无法读取未定义的属性“location”


您正在使用
setMarker()
函数从传递整个结果对象的Places回调中创建标记。但是将
LatLng
对象传递给执行
setMarker(fim)
操作的同一个函数

不使用相同的功能,您只需执行以下操作:

new google.maps.Marker({
    map: mapp,
    position: fim
});

而不是
setMarker(fim)

我知道,我已经看了很多例子,至少它们是一样的。我将在调用API和Places库的地方放一行(可能有什么地方出错了…)有没有办法将
LatLng
对象转换为方法以便它工作?因此,我不必仅为
LatLng
对象创建另一个
setMarker
函数。。。
fim = new google.maps.LatLng(-33.8665433, 151.1956316);
setMarker(fim);
setMarker(results[i]);
function setMarker(place) {

    var marker = new google.maps.Marker({
        map: mapp,
        position: place.geometry.location
    });
}
new google.maps.Marker({
    map: mapp,
    position: fim
});