ionViewDidLoad() {
let mapEle = this.mapElement.nativeElement;
let map = new BMap.Map(mapEle);
let geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == 0){
console.log(r.point);
let mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.enableScrollWheelZoom(true);
map.centerAndZoom(r.point, 9);
}
})
}
<ion-content class="map-page">
<div style="height: 500px; width: 100%" #mapCanvas id="map_canvas"></div>
</ion-content>
确定能够正确创建了map对象,获取定位r.point也正常,但是页面地图不显示,也没报错,请问是什么原因。
首先,你给的信息有点少,需要再详细一点。
我猜会不是地图容器没有高度?