Google映射本地Ionic v4-在Android设备上不显示

时间:2019-03-22 19:34:34

标签: google-maps ionic4 ionic-native

我在Android设备上看不到地图。

我已经为Android SDK创建了必要的API,然后按照Stackoverflow帖子中指示的步骤进行操作:

https://ionic.tutorials24x7.com/blog/implement-google-maps-in-ionic-4-for-android

但是我也没有使其工作,也没有给我任何错误。

loadMap(){

this.map = GoogleMaps.create('map_canvas', {

  camera: {

    target: {

      lat: 43.0741704,
      lng: -89.3809802
    },

    zoom: 18,
    tilt: 30

  }

});

}

异步onButtonClick(){

this.map.clear();

this.map.getMyLocation().then((location: MyLocation) => {
  console.log(JSON.stringify(location, null ,2));

  // Move the map camera to the location with animation
  this.map.animateCamera({
    target: location.latLng,
    zoom: 17,
    tilt: 30
  });

  // add a marker
  let marker: Marker = this.map.addMarkerSync({
    title: '@ionic-native/google-maps plugin!',
    snippet: 'This plugin is awesome!',
    position: location.latLng,
    animation: GoogleMapsAnimation.BOUNCE
  });

  // show the infoWindow
  marker.showInfoWindow();

  // If clicked it, display the alert
  marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe(() => {
    this._defaultService.mostrar_toast('clicked!', 2000);
  });
})
.catch(err => {
  this._defaultService.mostrar_toast(err.error_message, 2000);
});

}

如果您看到地图,如何运行“离子Cordova运行浏览器”,我想这可能是API的问题,但我不知道它可能是什么。

1 个答案:

答案 0 :(得分:0)

我刚刚解决了。 'ion-content具有具有以下属性的类:

.container{
   background-color: #eee;
   background-image: url ('../ assets / imgs / fondo.jpg');
   -webkit-background-size: cover;
   -moz-background-size: cover;
   background-repeat: no-repeat;
   background-size: cover;
}

当我删除该类时,它起作用了,尽管我不知道为什么