【问题标题】:Ionic DevApp: Google maps not showingIonic DevApp:谷歌地图未显示
【发布时间】:2018-04-14 21:24:13
【问题描述】:

我使用 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);
    });

  } 

【问题讨论】:

    标签: ionic-framework ionic3 ionic-serve ionic-devapp


    【解决方案1】:

    尝试添加locationOption

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

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

    【讨论】:

      猜你喜欢
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多