Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: AMap is not defined #59

Open
xiaobo530 opened this issue Feb 12, 2020 · 1 comment
Open

ReferenceError: AMap is not defined #59

xiaobo530 opened this issue Feb 12, 2020 · 1 comment

Comments

@xiaobo530
Copy link

在你的代码中,加入如下代码:

export class WelcomeComponent implements OnInit {
constructor() { }

ngOnInit() {
const dis = AMap.GeometryUtil.distance([123, 456], [123, 456]);
console.log(dis: ${dis});
}
}

提示错误:

ReferenceError: AMap is not defined

or 在别的工程中提示错误:

error TS2552: Cannot find name 'AMap'.

@xieziyu
Copy link
Owner

xieziyu commented Feb 13, 2020

AMap 需要在加载完地图之后使用,(在ngx-amap的naReady事件之后)。
如果缺少类型定义,需要安装 @types/amap-js-api

更新了 README.md,使用说明里的第5点。如果需要使用AMapLoaderService,需要更新到 3.0.1 版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants