Template.home.onCreated(function() {
// We can use the `ready` callback to interact with the map API once the map is ready.
GoogleMaps.ready('Map', function(map) {
// Add a marker to the map once it's ready
var marker = new google.maps.Marker({
position: map.options.center,
map: map.instance
});
var request = {
location: map.options.center,
radius:10000,
types:['restaurant']
}
console.log(request)
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request,callback);
console.log("Calling Service")
function callback(results,status)
{
console.log("Service Called")
if(status === google.maps.places.PlacesServiceStatus.OK)
{
console.log("Status OK")
for(var i = 0;i < results.length;i++)
{
console.log(results[i])
createMarker(results[i]);
}
}
}//end of callback
function createMarker(place)
{
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map:map,
position:place.geometry.location
});
}//end of create marker
})//end of google maps.ready function
});
我有一个简单的应用程序,用于搜索地图并在地图上的结果上放置标记。地图呈现正确,我在普通的html和js应用程序上尝试了相同的设置。我在我的流星应用程序中实现它时遇到了麻烦。应用程序一旦到达var service = new google.maps.places.PlacesService(map);
调用就会停止,我在控制台Uncaught TypeError: this.j.getElementsByTagName is not a function
上收到此错误。我正在使用dburles:google-maps
包。
答案 0 :(得分:0)
当您需要传递map.instance new google.maps.places.PlacesService(map.instance)时,您正在将地图传递给 new google.maps.places.PlacesService(地图) 强>