Google maps & infowindow


#1

Hi everybody! How are you?
I try to use google maps in my app, (based in this example https://www.joshmorony.com/create-a-nearby-places-list-with-google-maps-in-ionic-2-part-1). I want to do a map with stores, and when the user click in a point store, the app will shows a infoWindow with the store information, and if the user make click inside the infowindow, the app redirect to the store profile information. I create a code, but call many times to the click listener. My code:

var latLng = new google.maps.LatLng(lat, lng);

var infowindow = new google.maps.InfoWindow({
    content: '<a id="clickableItem" store="324" href="#">Store name</a> '
});

let marker = new google.maps.Marker({
  map: this.map,
  animation: google.maps.Animation.DROP,
  position: latLng
});

marker.addListener('click', function() {
  infowindow.open(this.map, marker);
});

google.maps.event.addListener(infowindow, ‘domready’, () => {
var clickableItem = document.getElementById(‘clickableItem’);

  clickableItem.addEventListener('click', (event: any) => {

    let storeId = clickableItem.getAttribute("store");
    console.log(storeId);
    // call to redirect function
  });
});

And other problem is when a infoInfow store is open, and the user clic in another store in map, the click method never executed. somebody have any idea how can solve this?

thanks!!!