S.R*_*sci 4 html javascript google-maps infowindow ionic2
嗨,我正在尝试从Google地图信息窗口中的按钮触发事件。问题是我无法以任何方式使其开火。
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
});
Run Code Online (Sandbox Code Playgroud)
任何提示将受到欢迎,谢谢。:)
小智 5
我已经为自己的项目找到了以下解决方案:(https://forum.ionicframework.com/t/ng-click-in-google-maps-infowindow/5537/6)
关键元素是您在下面的getElementbyId中查找的id =“ tap”。
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);
});
});
Run Code Online (Sandbox Code Playgroud)
希望这对您和其他人有帮助。
归档时间: |
|
查看次数: |
1962 次 |
最近记录: |