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()이 핀하게 항상지도의 중앙에 추가합니다.
다음 함수는지도에서 클릭 된 장소의 위도/경도를 반환해야합니다 :
addNewPlace(){
let newPlace = new google.maps.event.addListener(this.map, 'click', (event) => latLng);
}
와 나는 addMarker 기능에 삽입 할 위의 결과 (latLng를를) 원하는 :
를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 함수를 무시합니다 (아무 일도 일어나지 않으며 콘솔에서 오류가 발생하지 않습니다).