AngularJs2 - ng2-map无法正常工作/显示

时间:2016-06-26 09:27:41

标签: google-maps angular2-directives

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

Under是我的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>

我认为没有其他事情发生,并且没有错误日志告诉我哪里出错了。希望你能帮助我! =)

1 个答案:

答案 0 :(得分:0)

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