javascript - 呈现angular.js ui-map指令后如何触发 map 调整大小事件?

标签 javascript google-maps angularjs google-maps-api-3

ui-map在简单的 angular.js 页面上使用时,示例完美运行。 现在我正在使用 ui-router 并尝试在 View 中显示 map 。 发生的情况是 map 图 block 仅显示在 map 的一半上。 如果我调整窗口大小, map 会正确显示。

我认为我必须在呈现 View 后触发 Google map 调整大小事件,但如何触发?

google.maps.event.trigger(<myMapObject>, 'resize'); 

ng-map not rendering correctly

最佳答案

在调用触发器之前等待一段时间,我遇到了同样的问题并在此处找到解决方案:

AngularJS: map via Google Maps API v3 in a tab

window.setTimeout(function(){
    google.maps.event.trigger(map, 'resize');
},100);

关于javascript - 呈现angular.js ui-map指令后如何触发 map 调整大小事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18769287/

相关文章:

javascript - Scala.js 可以生成 TypeScript d.ts 类型绑定(bind)吗?

javascript - 在 index.html 中使用来自 cdn 链接的 React 组件

javascript - onfocusout 使用 jQuery Validate 在某些特定字段上

android - 如何传递要在谷歌地图上显示的地点的经纬度?

android - 将 Google maps api v2 添加到现有项目

javascript - 如何实现这个 sticky-header 向下滚动组件?

javascript - Googlemaps v3 路线

javascript - 下拉组件填充数据,只有虚拟数据有效

angularjs - 更改 Angular 指令中事件处理程序的范围

javascript - 单击一个 div 关闭另一个 div