javascript - Angular JS 谷歌地图渲染问题

标签 javascript jquery angularjs google-maps angular-google-maps

我在使用谷歌地图时遇到问题。

当前 map 显示如下。 enter image description here

<ui-gmap-google-map center='map.center' zoom='map.zoom'></ui-gmap-google-map>

var ngApp = angular.module('ngTest', ['ngResource', 'uiGmapgoogle-maps']);
    ngApp.config(
      ['uiGmapGoogleMapApiProvider', function (GoogleMapApiProviders) {
        GoogleMapApiProviders.configure({
          v: '3.17',
          china: true
        });
      }]);

会出现什么问题。 请帮忙,谢谢

最佳答案

正如 Angular Google Maps - FAQ 中的回答在部分渲染的 map 上:

If rendering starts before elements are full size, google maps calculates according to the smaller size. This is most commonly the case with a hidden element (eg, ng-show). To fix this, use "ng-if" instead, as this will wait to attach to the DOM until the condition is true, which should be after everything has rendered fully.

Angular Google map - DocumentationQuickstart可能有帮助。

此外,这篇文章 - Showing a google map in angular-ui modal也会很有帮助。

关于javascript - Angular JS 谷歌地图渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38156512/

相关文章:

javascript - 向下滚动时,Chrome(在 Android 上)地址栏不会消失

javascript - 未捕获的类型错误 : Cannot read property 'removeLayer' of undefined Vue and Leaflet

javascript - 使 select2 框足够宽以容纳内容

javascript - 使用 jquery 更改文本和类

javascript - jQuery.contents() 给出了一个奇怪的结果

javascript - 使用 Angular 按下按钮会导致 v2.show 不是函数错误

javascript - 如何在浏览器中进行视频捕获?

javascript - 图像映射多工具提示引用

javascript - 如何调用包含在字符串中的函数?

angularjs - 使用 AngularFire 根据 id 连接路径之间的数据