1

我使用 JavaScript SDK 来显示地图。

它在浏览器上运行,但是当我在开发应用程序上打开它时,页面显示空白页面。

 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);
    });

  } 
4

1 回答 1

0

尝试添加 locationOption

let locationOptions = { timeout: 30000, enableHighAccuracy: true };

并像这样传递给 getCurrentPosition this.geolocation.getCurrentPosition(locationOptions).then((p‌​osition) => {

于 2017-11-02T11:57:01.760 回答