I am using Ionic 2 and the google maps cordova plugin.
"cordova-plugin-googlemaps": "^2.0.11"
I cannot get this listener to fire.
The marker is added to the map but the click event does not fire the alert.
Thanks for the help!
let latlng = new LatLng(spot.lat, spot.long);
let markerOptions: MarkerOptions = {
'position': latlng,
'animation': 'drop'
};
this.map.addMarker(markerOptions).then((marker: Marker) => {
marker.addEventListener(GoogleMapsEvent.MARKER_CLICK).subscribe(e => {
alert('foo');
});
});
Additional Information
@ionic-native/core: 'version': 3.7.0
@ionic-native/google-maps: 'version': '4.3.0'
import {
GoogleMaps,
GoogleMap,
GoogleMapsEvent,
GoogleMapOptions,
CameraPosition,
MarkerOptions,
LatLng,
Marker
} from '@ionic-native/google-maps';
I am looping through multiple lat long coordinates and adding them to the map. The event never gets fired for any of them.
When I try to attach the even to just one of the markers it does not work either.
Lastly if I put another alert it does not fire. Is it possible the add marker promise is not resolving?
this.map.addMarker(markerOptions).then((marker: Marker) => {
alert('in here');
marker.addEventListener(GoogleMapsEvent.MARKER_CLICK).subscribe(e => {
alert('foo');
});
});

@ionic-native/coreand@ionic-native/google-mapsdo you use? At least the above code should work. - wf9a5m75