【问题标题】:AngularJs2 - ng2-map not working/showing upAngularJs 2 - ng 2-map 不工作/显示
【发布时间】:2016-06-26 09:27:40
【问题描述】:

当我在一个主页上工作时,我真的需要一个简单的地图,比如我的 angular2 应用程序中的谷歌地图。应该有地图的地方什么也没有显示。当然,我只是错过了一些东西。

下面是我的 System.config

<!-- Configure SystemJS -->
<script>
    System.config({
        packages: {
            app: {
                format: 'register',
                defaultExtension: 'js'
            },
            'ng2-map': {
                main: 'index.js',
                defaultExtension: 'js'
            }
        },
        map: {
            'ng2-map': 'node_modules/ng2-map'
        }
    });
    System.import('app/js/main').then(null, console.error.bind(console));
</script>

然后是组件尝试使用 map 指令。

import { NG2_MAP_DIRECTIVES } from "ng2-map";

@Component({
    selector: 'contact',
    templateUrl: '../../../html/contact.html',
    directives: [NG2_MAP_DIRECTIVES]
})

最后是 html 部分:

<div class="ContentRow-Paralax" id="secondAbout">
<div class="topstripe">
</div>
<div class="stripe">
    <h2>Trollolol</h2>
</div>

<div class="ContentRow-Paralax">
<ng2-map id="map" [center]="[40.74, -74.18]" default-style="false"></ng2-map>

我认为没有太多其他事情发生,也没有错误日志可以告诉我哪里出错了。希望你能帮帮我! =)

【问题讨论】:

    标签: google-maps angular2-directives


    【解决方案1】:

    您可能需要定义默认标记或在地图容器上设置一些 CSS。在我这样做之前,我的地图不会显示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-08
      • 2015-12-12
      • 2014-12-23
      相关资源
      最近更新 更多