Google Maps SDKを使用してIonic 2アプリを構築しています。関数の結果をプロパティに渡す
マップ上にマーカーを追加できるようにしたいと考えています。
ボタンクリックでマーカーを追加私のコードは次のようになります。
addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter()
});
let content = "<h4>Information!</h4>";
this.addInfoWindow(marker, content);
}
位置:this.map.getCenter()は、ピンは常に地図の中心に追加できます。
: addMarker関数に挿入するaddNewPlace(){
let newPlace = new google.maps.event.addListener(this.map, 'click', (event) => latLng);
}
及びIは、(緯度経度)上記からの結果が欲しい:
次の関数は、地図をクリックした場所の緯度/経度を返すべき
addMarker(){
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: newPlace
});
let content = "<h4>Information!</h4>";
this.addInfoWindow(marker, content);
}
どうすればいいですか? 今のところ、ブラウザは単に私のaddNewPlace機能を無視します(何も起こらず、コンソールにエラーはありません)。