# Add click event to marker ionic native

**URL:** <https://forum.ionicframework.com/t/add-click-event-to-marker-ionic-native/97081>\
**Category:** Ionic Native\
**Created:** [July 5, 2017, 7:44pm UTC](https://forum.ionicframework.com/t/add-click-event-to-marker-ionic-native/97081 "2017-07-05T19:44:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![francocor4](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@francocor4](https://forum.ionicframework.com/u/francocor4)\
**Post date:** [July 5, 2017, 7:44pm UTC](https://forum.ionicframework.com/t/add-click-event-to-marker-ionic-native/97081/1 "2017-07-05T19:44:34Z")

</div>

How can i add a click event to my markers?  
I already try this:

```auto
 markers[i].on('GoogleMapsEvent.MARKER_CLICK').subscribe(() => {
                                                
 });

```

but i get this error:

`markers[i].on is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: markers[i].on is not a function`

My marker objects is this:  
\_\_zone\_symbol\_\_state:true  
\_\_zone\_symbol\_\_value:undefined  
**proto** :Object

is right? i added to my markers arrays when this happens:

```auto
for (let i = 0; i < locations.length; i++) {
       let latlng: LatLng = new LatLng(locations[i].lat, locations[i].lng);

      let markerOptions: MarkerOptions = {
            position: latlng,
            title: locations[i].id
        };

        const marker: Marker = map.addMarker(markerOptions)
             .then((marker: Marker) => { 
           });
//HERE I ADD MY MARKER TO MARKERS IS OKAY?
        this.markers.push(marker);
      }
 resolve(this.markers);

```

Also i try:

```auto
markers[i].addListener('click', function () {
                                               
 });

```

But i get:  
`markers[i].addListener is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: markers[i].addListener is not a function`

---

<div class="post-metadata">

**Author:** ![webcomapps](https://avatars.discourse-cdn.com/v4/letter/w/b487fb/32.png) [@webcomapps](https://forum.ionicframework.com/u/webcomapps)\
**Post date:** [July 5, 2017, 8:35pm UTC](https://forum.ionicframework.com/t/add-click-event-to-marker-ionic-native/97081/2 "2017-07-05T20:35:48Z")

</div>

```
    //Marker + infowindow + angularjs compiled ng-click
    var contentString = "<div><a ng-click='clickTest()'>Click me!</a></div>";
    var compiled = $compile(contentString)($scope);

    var infowindow = new google.maps.InfoWindow({
      content: compiled[0]
    });

    var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title: 'Uluru (Ayers Rock)'
    });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
```

---

<div class="post-metadata">

**Author:** ![francocor4](https://avatars.discourse-cdn.com/v4/letter/f/c0e974/32.png) [@francocor4](https://forum.ionicframework.com/u/francocor4)\
**Post date:** [July 5, 2017, 8:56pm UTC](https://forum.ionicframework.com/t/add-click-event-to-marker-ionic-native/97081/3 "2017-07-05T20:56:25Z")

</div>

I am in ionic 2 and angular 4 that doesnt work for me. Also is the javascript way what you posted. I need the ionic native way using the cordova plugin for google maps
