谷歌放置API不适用于Meteor
google places api not working for meteor
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
包。
当您需要传递 map.instance new google.maps.places.PlacesService(map.instance) 时,您正在将地图传递给新的google.maps.places.PlacesService(map)
请参阅链接以获取参考 https://github.com/dburles/meteor-google-maps#ready
相关文章:
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- PHP中的setcookie仅适用于localhost
- html5 drawImage适用于firefox,而不是chrome
- 谷歌地图根本不适用于Meteor-iOS
- 提供“;onClick"适用于iPad(触摸屏)和桌面用户的默认功能
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- ResolveUrl是否适用于././也
- Firebase updateChildValues适用于IOS,但不适用于Web和Android
- JavaScript警报适用于int,但不适用于string
- SQLite插件适用于Mac和Windows,但不适用于手机上的Safari
- Regex Replace仅适用于Last Match
- window.onload适用于aspx页面,但不适用于普通html
- Jquery Ajax POST不工作.适用于GET
- 画布上的自定义字体仅适用于safari
- Javascript仅适用于alert()和Debug模式
- JS适用于Firefox和Safari,但不适用于Chrome.此处'是我的网站
- Regex不适用于Firefox,但适用于Chrome
- 通过单击主菜单外部关闭子菜单'不适用于IE,但适用于Firefox&铬
- AngularJS$http.post没有'不适用于Chrome,仅适用于IE
- JS插件,适用于Meteor