渲染后,angular-google-map-container元素为空

问题描述 投票:1回答:1

我使用angular-google-mapstypescriptrequirejs。我用下一个代码初始化地图:

Requirejs配置:

    require.config({
    urlArgs: 'bust=' + (new Date()).getTime(),
    paths: {
         ....
        'maps': '/scripts/angular/angular-google-maps.min',
        'lodash': '/scripts/angular/lodash.min',
        'app': '/app/app'
    },
    shim: {
        ...
        'maps': { deps: ['lodash', 'angular'] },
        'angular-cookies': { deps: ['angular'] }
    }
});

require(['jquery', 'angular', 'bootstrap', 'angular-ui-router', 'angular-cookies', 'maps', 'app'],
    ($: JQueryStatic, angular: ng.IAngularStatic) => {
        $(() => {
            angular.bootstrap(document, ['app']);
        });
    });

的index.html

<html xmlns="http://www.w3.org/1999/xhtml">
    ...
    <script src='//maps.googleapis.com/maps/api/js?sensor=false'></script>
    <script src="Scripts/require.js" data-main="/app/config.js"></script>
</body>
</html>

在控制器视图中我有下一个布局:

                <div class="row">
                <ui-gmap-google-map center='map.center' zoom='map.zoom' id="myGoogleMap"></ui-gmap-google-map>
            </div>

在控制器中我有来自here的默认设置

渲染页面后,我看到下一个布局:

<ui-gmap-google-map center="map.center" zoom="map.zoom" id="myGoogleMap" class="ng-isolate-scope">
<div class="angular-google-map">
    <div class="angular-google-map-container"></div>
    <div ng-transclude="" style="display: none"></div>
</div>

有谷歌api脚本和角度地图指令被初始化,但地图不显示。为什么?

angularjs requirejs typescript angular-google-maps
1个回答
3
投票

我只是遇到了同样的问题,因为我没有将固定高度设置为.angular-google-map-container一旦我设置了.angular-google-map-container {height:350px;它开始出现了

© www.soinside.com 2019 - 2024. All rights reserved.