cordova-plugin-googlemaps: addMarker callback not executed

I’m using ionic 2 and executing on Android M (device, not emulator) I need to add a marker to a map and retain a reference so I can rotate it later. If I add it via e.g.

this.mapping.map.addMarker({'position': coords, 'icon': icon, 'rotation': 90}, (marker) => {
  alert("TEST");
});

The marker is placed but the callback is never executed. I’ve put some debugging output into googlemaps-cdv-plugin.js and everything looks like it’s working fine, I’ve verified via alerts that typeof callback === “function” returns true and that both self and marker in callback.call are objects.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Brilliant thank you! I’m using v2 now without the wrapper and it works. Thank you so much for your help. I think I’ve found a very minor bug in the marker btw. Lines 238 to 245 in Marker.js read

Marker.prototype.setRotation = function(rotation) {
    if (!rotation) {
        console.log('missing value for rotation');
        return false;
    }
    this.set('rotation', rotation);
    return this;
};

The issue is that 0 and 0.0 are both falsy, so setRotation(0) will not work. Perhaps something like

if (!rotation && typeof rotation !== 'number')

or even just the second condition would be better.