JavaScript:
var ref = firebase.database().ref('Location/Lat');
var latitude;
var longitude;
ref.on("value", function(snapshot) {
console.log(snapshot.val());
latitude = snapshot.val().Latitude;
longitude = snapshot.val().Longitude;
console.log(latitude, longitude);
userLocation(latitude, longitude);
}, function (error) {
console.log("Error: " + error.code);
});
// Find user location
function userLocation (latitude, longitude){
console.log(latitude, longitude)
try{
// Get position fn
function position (c, lt, lg){
console.log(c.coords);
let lat = lt.latitude;
let lng = lg.longitude;
let coords = [lng, lat];
// Show map location
mapBoxFn(coords);
};
// Error fn
function error (err){
alert(`ERROR(${err.code}): ${err.message}`);
};