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!