Google maps resizeevent未启动
我正在使用流星谷歌地图。我试图像这样调整地图的大小Google maps resizeevent未启动,google-maps,google-maps-api-3,meteor,Google Maps,Google Maps Api 3,Meteor,我正在使用流星谷歌地图。我试图像这样调整地图的大小google.map.event.trigger(GoogleMaps.maps.exampleMap,resize),但问题是它不起作用。我的地图隐藏在选项卡中,因此每当我打开该选项卡时,地图都不会显示。我尝试使用调整大小功能,但也没有做任何事情。有人能告诉我为什么它不显示吗 添加的代码 映射HTML 页面加载时,“内容”选项卡处于打开状态。当用户单击li中的where链接时,where选项卡打开。第一次打开时,我看不到地图,但在调整浏览器大小
google.map.event.trigger(GoogleMaps.maps.exampleMap,resize)
,但问题是它不起作用。我的地图隐藏在选项卡中,因此每当我打开该选项卡时,地图都不会显示。我尝试使用调整大小功能,但也没有做任何事情。有人能告诉我为什么它不显示吗
添加的代码
映射HTML
页面加载时,“内容”选项卡处于打开状态。当用户单击li中的where链接时,where选项卡打开。第一次打开时,我看不到地图,但在调整浏览器大小后,地图将加载。我试图自己触发调整大小事件,但也没有成功首先,您的代码正在使用
google.map.event
。但是Google地图的名称空间是Maps
而不是map
。i、 e.应该是google.maps.event
其次,调用trigger
时,需要将事件名称作为字符串传递,即google.maps.event.trigger(GoogleMaps.maps.exampleMap,'resize')
见:
google.maps.event.trigger(GoogleMaps.maps.exampleMap.instance , 'resize')
我正在使用流星谷歌地图。这是我写的,但我可能会不小心删掉那部分。我试过编辑这个问题,但我做不到。你的问题中的一点点代码都没有使用Meteor;这都只是标准的谷歌地图API代码。你应该用更多的代码来更新你的问题,充分展示你在做什么,这样我们就可以复制你遇到的问题。你知道我为什么要面对这个问题吗?你能告诉我一件事,为什么谷歌地图不能在手机上工作吗。我没有任何地图,这是一个完全空白的分区。这是一张图片
Template.body.helpers({
exampleMapOptions: function() {
// Make sure the maps API has loaded
if (GoogleMaps.loaded()) {
// Map initialization options
return {
center: new google.maps.LatLng(-37.8136, 144.9631),
zoom: 8
};
}
}
});
Template.body.onCreated(function() {
// We can use the `ready` callback to interact with the map API once the map is ready.
GoogleMaps.ready('exampleMap', 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
});
});
});
Template.body.event({
'click .where a':function(){
debugger;
google.maps.event.trigger(GoogleMaps.maps.exampleMap , 'resize');
}
});
google.maps.event.trigger(GoogleMaps.maps.exampleMap.instance , 'resize')