元気?私はIonic 3チュートリアルのGoogle Mapsを勉強しています。私はそこに説明されていることをすべて実行しましたが、プロジェクトが開始されると、このエラーが表示されます。私は多くを調査しましたが、何も機能しません。ありがとう!IONIC 3:未知(約束):ReferenceError:Googleが定義されていないReferenceError
home.tsあなたのコードであることをしなかったところ以下のようにあなたがdeclare
にそれを必要とする
import { Component, ViewChild, ElementRef } from '@angular/core';
import { NavController } from 'ionic-angular';
import { IonicPage } from 'ionic-angular';
declare var google;
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild('map') mapElement:ElementRef;
map: any;
start = 'chicago, il';
end = 'chicago, il';
directionsService = new google.maps.DirectionsService;
directionsDisplay = new google.maps.DirectionsRenderer;
constructor(public navCtrl: NavController) {
}
ionViewLoad(){
this.initMap();
}
initMap(){
this.map = new google.maps.Map(this.mapElement.nativeElement,
{
zoom: 7,
center: {lat: 41.85, lng: -87.65}
});
this.directionsDisplay.setMap(this.map);
}
calculateAndDisplayRoute(){
this.directionsService.route({
origin: this.start,
destination: this.end,
travelMode: 'DRIVING',
}, (response, status) => {
if(status == 'OK'){
this.directionsDisplay.setDirections(response);
}else{
window.alert('Directions request failed due to ' +
status);
}
});
}
}
で同じ問題について
これはコルドバのプラグインですか?あなたは装置で走っていますか? –
いいえ。ノートパソコンのブラウザ。はい、コードワプラグインです。 –
コードワインプラグインには「イオンサービング」が搭載されていません。エミュレータ/デバイス –