ngx-amap icon indicating copy to clipboard operation
ngx-amap copied to clipboard

ReferenceError: AMap is not defined

Open xiaobo530 opened this issue 4 years ago • 1 comments

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

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'.

xiaobo530 avatar Feb 12 '20 13:02 xiaobo530

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

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

xieziyu avatar Feb 13 '20 00:02 xieziyu