1.前言
注册高德地图成为开发人员
https://lbs.amap.com/
2.申请key
链接https://lbs.amap.com/dev/key/app
3.在app上添加地图
4.建一个html
5.样式
.container {
width: 100%;
height: 100%;
}
引入
如果没有typings.d.ts 请创建
declare var AMap: any;
使用
@ViewChild(‘container’, {static: true}) id: ElementRef;
map: any; // 地图对象
ionViewDidEnter() {
this.initMap();
}
initMap(): void {
this.map = new AMap.Map(this.id.nativeElement, {
center: [114.924689, 27.830479], // 中心点坐标
resizeEnable: true,
zoom: 17
});
}
效果