0
谷歌地图显示在浏览器中,但是当我运行命令 ionic run android
它成功地建立并启动应用程序,但一切工作正常,除了谷歌地图没有错误在chrome://inspect
它只是说DEVICE READY FIRED AFTER 630 ms
但没有错误为谷歌地图。我确实在console.developers.google.com上注册了应用程序,获得了密钥并在www/index.html
的头部使用它,但仍然没有任何更改。请帮助谢谢你。 home.ts
(Map函数是这个文件里面)谷歌地图的问题 - 离子2
// Get the current location
Geolocation.getCurrentPosition().then((position) => {
// Set latitude and longtitude variable
this.lat = position.coords.latitude;
this.long = position.coords.longitude;
// This function will get the name of the city where user is located
this.getCityName(this.lat, this.long);
// this function sets up the google map
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var mapi = new google.maps.Map(this.mapDiv.nativeElement, mapOptions);
// Below code is provided by a ai pollution control website (http://aqicn.org/faq/2015-09-18/map-web-service-real-time-air-quality-tile-api/)
// haven't changed anything in below code copied as it is from web
var waqiMapOverlay = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return 'http://tiles.aqicn.org/tiles/usepa-aqi/' + zoom + "/" + coord.x + "/" + coord.y + ".png?token=_TOKEN_ID_";
},
name: "Air Quality",
});
// Insert above received data into map
mapi.overlayMapTypes.insertAt(0,waqiMapOverlay);
`
解决了我的问题。谢谢您的回答。 –