【问题标题】:angular2-google-maps with angular2 appangular2-google-maps 与 angular2 应用程序
【发布时间】:2017-06-10 04:47:27
【问题描述】:

我已经用 angular2 应用程序设置了angular2-google-map

这里是 app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';
import { AgmCoreModule} from 'angular2-google-maps/core';
@NgModule({
  imports:      [ BrowserModule, AgmCoreModule.forRoot({apiKey: 'AIzaSyAe3ci9yavJcWt7MaJE8DusAuZo-QeRqkU'}) ],
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ],
})
export class AppModule { }

我使用命令安装了 angular2-google-maps,

npm install angular2-google-maps --save

已成功安装。当我使用 npm start 运行应用程序时, 它显示一条错误消息,

http://localhost:3000/angular2-google-maps/core加载失败 资源:服务器响应状态为 404(未找到)

但我可以在 node_modules 中看到 angular2-google-maps 文件夹。 什么问题?

【问题讨论】:

  • 使用 webpack/System.js 作为模块加载器?
  • 在 npm install 的时候,有没有抛出任何警告或异常,你现在至少可以尝试 npm install 然后缓存清理然后重新安装
  • @RahulSingh 不,它不会显示任何错误
  • @PankajParkar 没有使用具有 system.js 的快速启动项目
  • 你试过这种方法吗? stackoverflow.com/questions/35970965/…

标签: google-maps angular typescript angular2-google-maps


【解决方案1】:

您忘记在system.config.js 中添加map

'angular2-google-maps/core': 'npm:angular2-google-maps/core/core.umd.js'

通过将上述添加到 systemjs 配置。当您尝试导入 angular2-google-maps/core 时,模块加载器将理解加载 core.umd.js

【讨论】:

  • 现在错误消失了,它显示加载资源失败:服务器响应状态为 404(未找到)
  • 检查css文件是否存在于该路径
  • 我也解决了这个问题,现在地图显示空白的灰色区域,知道吗?
  • 不确定,请多指教
猜你喜欢
  • 1970-01-01
  • 2017-04-08
  • 1970-01-01
  • 1970-01-01
  • 2017-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多