I’m trying to get the location when the user just open the app but It only displays a grey screens as shown in The image attached
I attached the code that I am using and an the image I get in the physical device.
if (Meteor.isClient) {
var MAP_ZOOM = 15;
// Load the Google Maps API on startup
Meteor.startup(() => {
GoogleMaps.load({
v: '3',
key: 'AIzaSyAR3vH1uNiILAHgIA5Ct5b56U2KkeBxRFk',
libraries: 'geometry,places'
});
});
Template.geocompleteExample.onRendered(function () {
this.autorun(() => {
// success callback
function success(position) {
lat: Session.set('latitude', position.coords.latitude);
lng: Session.set('longitude', position.coords.longitude);
let crd = position.coords;
console.log('Your current position is:');
console.log(`Latitude : ${crd.latitude}`);
console.log(`Longitude: ${crd.longitude}`);
console.log(`More or less ${crd.accuracy} meters.`);
if (GoogleMaps.loaded() && crd) {
$('#place2').geocomplete({
map: $("#map"),
location: [crd.latitude, crd.longitude]
});
}
};
// error callback
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
};
// geolocation options
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
// now try to get the user's position
navigator.geolocation.getCurrentPosition(success, error, options);
});
});
}