【发布时间】:2017-06-20 18:21:59
【问题描述】:
我正在尝试在我的应用中包含谷歌地图。但我没有得到 google is not defined 错误。 我已经添加了插件
ionic plugin add cordova-plugin-geolocation
npm install --save @ionic-native/geolocation
我的代码是这样的:
ionViewDidLoad(){
this.loadMap();
}
loadMap(){
this.geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
}, (err) => {
console.log(err);
});
}
有人可以帮我解决这个问题吗?
【问题讨论】:
-
你是如何加入谷歌地图的? javascript 库还是 ionic 原生插件?
标签: cordova google-maps ionic3