# Handle click event from class

**URL:** <https://forum.ionicframework.com/t/handle-click-event-from-class/159779>\
**Category:** ionic-v3\
**Created:** [March 22, 2019, 4:00pm UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779 "2019-03-22T16:00:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamGelineau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adamgelineau/32/123043_2.png) [@AdamGelineau](https://forum.ionicframework.com/u/AdamGelineau)\
**Post date:** [March 22, 2019, 4:00pm UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779/1 "2019-03-22T16:00:02Z")

</div>

Hey guys,

I’m trying to open a Popover page, but it’s always showing at the middle of the screen. I think it’s because the button I click isn’t an ion component in the html file, but a Google maps marker in my ts file.

```auto
google.maps.event.addListener(friendMarker, 'click', (event) => {
    that.presentPopover(event, friendMarker, oneFriend)
});

```

So, I listen to the click event on my Maps marker, and when I click on it, I open my Popover page, just like this:

```auto
presentPopover(ev, friendMarker, oneFriend) {
    this.map.panTo(friendMarker.position);
    let popover = this.popoverCtrl.create(ContactPopoverPage, {friend: oneFriend});
    popover.present({
        ev: ev
    });
}

```

Unfortunately, I think my event isn’t the one the Popover page is waiting for… Because the popover just pop without the arrow and is always right in the middle of the screen.

So the question is : Do you guys know how to pass the right event to my Popover page from my ts file ?

Thanks mates !

---

<div class="post-metadata">

**Author:** ![irvingprog](https://avatars.discourse-cdn.com/v4/letter/i/7ab992/32.png) [@irvingprog](https://forum.ionicframework.com/u/irvingprog)\
**Post date:** [March 22, 2019, 5:24pm UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779/2 "2019-03-22T17:24:20Z")

</div>

Hi @AdamGelineau

Reading a little bit Google Maps documentation. [https://developers.google.com/maps/documentation/javascript/events](https://developers.google.com/maps/documentation/javascript/events)

I think you should fire the Popover element on Marker click event callback.

Something like this:

```auto
  marker.addListener('click', function(event) {
    that.presentPopover(event, this, oneFriend);
  });

```

Regards.  
Irving.

---

<div class="post-metadata">

**Author:** ![AdamGelineau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adamgelineau/32/123043_2.png) [@AdamGelineau](https://forum.ionicframework.com/u/AdamGelineau)\
**Post date:** [March 22, 2019, 5:36pm UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779/3 "2019-03-22T17:36:47Z")

</div>

Yeah, nice idea, I’ll try this on Monday though !  
Thanks, I’ll give feedback soon 😉

---

<div class="post-metadata">

**Author:** ![AdamGelineau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adamgelineau/32/123043_2.png) [@AdamGelineau](https://forum.ionicframework.com/u/AdamGelineau)\
**Post date:** [March 25, 2019, 9:16am UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779/4 "2019-03-25T09:16:22Z")

</div>

So, after trying your solution, unfortunately it doesn’t work 😕

Let me show you what i tried:

```auto
let friendMarker = new google.maps.Marker({
              position: position,
              title: 'friend',
              icon: {
                url: url,
                scaledSize: new google.maps.Size(42, 42), // scaled size
              },
              optimized: false
            });

```

```auto
friendMarker.addListener('click', function(event) {
     that.presentPopover(event, oneFriend);
});

```

When I click on my Maps marker, my Popover still appears in the middle of the page, and not on my marker.

---

<div class="post-metadata">

**Author:** ![AdamGelineau](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adamgelineau/32/123043_2.png) [@AdamGelineau](https://forum.ionicframework.com/u/AdamGelineau)\
**Post date:** [March 25, 2019, 10:47am UTC](https://forum.ionicframework.com/t/handle-click-event-from-class/159779/5 "2019-03-25T10:47:42Z")

</div>

Finally found out a solution which is ok to me, I’m using Google Maps InfoWindow instead of Ionic Popover component.

Thanks anyway for helping me though 😉 Appreciate
