Hi i'm trying to fire an event from a button inside a google maps infowindow. the problem is that i can´t make it fire by any mean.
addMarket(latitud, longitud, sensorData) {
let marker = new google.maps.Marker({
draggable: false,
position: { lat: latitud, lng: longitud },
map: this.map,//set map created here
title: sensorData.sensor
});
marker.addListener('click', function () {
infowindow.open(this.map, marker);
});
let bodyMessege = 'Nombre del Sensor: ' + sensorData.sensor + '<br>' +
'Componente Descripcion: ' + sensorData.componentDesc + '<br>' +
' description: ' + sensorData.description + '<br>' +
' Tipo de sensor: ' + sensorData.type + '<br>' +
' Unidad de sensor: ' + sensorData.unit + '<br>' +
'Tipo de dato: ' + sensorData.dataType + '<br>' +
' <button ion-button (click)="this.navCtrl.push(DetalleSensorPage)" >Default</button>';
// ' <button ion-button="" onclick=console.log("log");' anda
//this.pushPage=DetalleSensorPage;
var infowindow = new google.maps.InfoWindow({
content: bodyMessege
});
Any tip will be welcome thanks. :)
I have found this solution for my own project: ( https://forum.ionicframework.com/t/ng-click-in-google-maps-infowindow/5537/6)
The key element is the id="tap" that you look for at the getElementbyId below.
let content = '<div class="infowindow"><p id="tap">your text here</p></div>';
let infoWindow = new google.maps.InfoWindow(
{
closeBoxURL: "",
content: content
}
);
infoWindow.open(this.map, marker);
google.maps.event.addListenerOnce(infoWindow, 'domready', () => {
document.getElementById('tap').addEventListener('click', () => {
//alert('Clicked');
console.log("touch");
this.closeInfoViewWindow(infoWindow);
this.openEventDetailModal(event);
});
});
hope this will help you and others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With