Bug inside Google Map with Marker


#1

Hi!

I try to add markers to a GoogleMap with ionic 2. But no matter what I try, each attempt ends with a failure … I see the map, my position, but not my markers

Here is my code:

loadMap(){
Geolocation.getCurrentPosition().then((position) => {

  this.map = new GoogleMap('map', {
    'backgroundColor': 'white',
    'controls': {
      'compass': false,
      'myLocationButton': true,
      'indoorPicker': true,
      'zoom': false,
    },
    'gestures': {
      'scroll': true,
      'tilt': true,
      'rotate': true,
      'zoom': true
    }
  });
});

Geolocation.watchPosition().subscribe(position => {
  if ((position as Geoposition).coords != undefined) {
    var geoposition = (position as Geoposition);

    //this.map.setCenter(location);

    //On va chercher les autres marqueurs
    var User = Parse.Object.extend("User");
    var query = new Parse.Query(User);
    query.find({
      success: function(results) {
        for(var i= 0; i < results.length; i++){
          if(results[i].attributes.coord_gps != undefined){
            let location = new GoogleMapsLatLng(results[i].attributes.coord_gps.longitude,results[i].attributes.coord_gps.latitude);
            let markerOptions: GoogleMapsMarkerOptions = {
              position: location,
              visible : true,
              title: 'Ionic'
            };
            console.log("Ajout d'un marker !");
            this.map.addMarker(markerOptions);
            console.log("Marker ajouté !");
        }
      }
    },
      error: function(error) {
      }
    });
  } 
});

}

Thanks for helping me! :slight_smile:


#2

for some reason the marker can only be seen on my device…using server or chrome://inspect the marker just goes hidden


#3

Hello chanyap92, even on my device, marker does not showing…