Hi I have searched since many hours, I hope you can help me :)
Idea
I want to display a Page if you click on an InfoWindow on google Maps. (Using a ModalController from Ionic 2)
Problem
Click doesn't work..
var infoWindow = new google.maps.InfoWindow({
content: '<h2 (click)="goToProductPage(product)">Click me</h2>'
});
goToProductPage(product :any){
let modal = this.modalCtrl.create(ProductPage, product);
modal.present();
}
Sadly this doesn't work, I tried also with a content node, with onclick=""
, with javascript functions..
Here is another question with the same problem unsolved.
Best regards, Luis
EDIT
setProductMarker(product :any, productLocation :any){
var contentWindow = "<h2 id='clickableItem'>Click me</h2>" + product.productName + "<img src='" + product.imgUrl + "' width='60' height='60' /> <br/>" + product.date
var clickableItem = document.getElementById('clickableItem');
clickableItem.addEventListener('click' , () => {
this.goToProductPage(product);
});
var productMarker = new google.maps.Marker({
position: new google.maps.LatLng(JSON.parse(productLocation).latitude, JSON.parse(productLocation).longitude),
map: this.map,
title:"Product"
})
var infoWindow = new google.maps.InfoWindow({
content: contentWindow
});
infoWindow.addListener('click', () => {
alert("yeah");
console.log("yeah");
});
productMarker.addListener('click', event => {
infoWindow.open(this.map, productMarker);
this.productNow = product;
});
}