Google Maps marker not showing


#1

I installed native cordova plugin https://github.com/mapsplugin/cordova-plugin-googlemaps
Then I used this tutorial to show GMaps https://ionicframework.com/docs/native/google-maps/
Which worked but not very well.

So I used this and it works perfectly, but I can’t add marker, it’s not showing up

let location = new GoogleMapsLatLng(-34.9290,138.6010);

    this.map = new GoogleMap('map', {
      'backgroundColor': 'white',
      'controls': {
        'compass': true,
        'myLocationButton': true,
        'indoorPicker': true,
        'zoom': false
      },
      'gestures': {
        'scroll': true,
        'tilt': true,
        'rotate': true,
        'zoom': true
      },
      'camera': {
        'latLng': location,
        'tilt': 0,
        'zoom': 15,
        'bearing': 50
      }
    });
    this.map.addMarker({
        'position': location,
        'visible': true,
        'markerClick': function(marker) {
            
         }
    });

EDIT SOLVED:
I had to add “addMarker” inside GoogleMapsEvent:MapReady like this:

this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() =>
{
console.log(‘Map is ready!’);
this.map.addMarker({
‘position’: location,
‘visible’: true,
‘markerClick’: function(marker) {

  }

});
});

Maybe documentation should be updated?


#2

Great that you fixed your problem.

You can a) edit the docs page yourself or b) open an issue on the ionic-native repo on Github. Then this will be taken care of, here it will probably be missed.


#3

@dariot thanks for your help man, you saved my time