Callbacks Not Firing - Google Maps


#1

Are Google Maps callbacks broken in Ionic 2? I’m trying to reload markers when a user drags on a map view, but none of my callbacks are firing. I tried adding the following callbacks in ionViewDidLoad, but they are never fired. I also noticed that events.js in the Google Maps library includes a lot of callbacks that throw errors when I try to use them.

I’m using the following import line:
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng, CameraPosition } from ‘ionic-native’;

I’ve tried including the callbacks wrapped in both the MAP_READY callback and outside of it.

      this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
          this.map.addEventListener(GoogleMapsEvent.CAMERA_CHANGE).subscribe(() => {
            console.log("Camera has changed!");
          });

          this.map.addEventListener(GoogleMapsEvent.MAP_CLICK).subscribe(() => {
            console.log("Map clicked!");
          });
      });

#2

Figured it out. Looks like the enums for callbacks are broken. If you use the raw strings, (like ‘camera_move’), it works.


#3

Same here. i will try your solution


#4

I guess the versions @ionic-native/core and @ionic-native/google-maps are mismatched or too old.,