错误:未捕获(承诺):ReferenceError:google未在离子3中定义

时间:2017-06-20 09:14:46

标签: cordova google-maps ionic3

我正在尝试在我的应用中加入谷歌地图。但我没有得到谷歌没有定义错误。 我添加了插件

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

  }

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

您安装的插件(cordova-plugin-geolocation)只为您提供了用户位置。它不包含Google Maps API。

要使用Google地图,您可以: