[Reactive Geolocation Library] ReactiveGeoLocation does not not have a callback function? How to solve screen freeze
Question
Forge component by Justin James

I am using the ReactiveGeoLocation library to get the location frm the user, as long as the user agrees the latitude and longitude are passed on just fine. 

The problem occurs when the User denies the use of the location, at this point the action freezes. I saw on multiple forums that in the JavaScript version a callback function is possible, is it possible to implement this or is there maybe another solution.

My usercase is.

User when agrees he gets his location on screen, when user denies user gets the predefined fixed location on screen.

Thank you for your help!

Best regards,

Mario

Solution

Eventualy I found a solution for my problem by adding the following code:


navigation = navigator.geolocation;

navigation.getCurrentPosition(success, failure);

function success(position){

$parameters.Lat =  position.coords.latitude;

$parameters.Long =  position.coords.longitude;

$resolve();

}

function failure(error){

console.log(error.code);

$resolve();

}


In this case when rejected by the user it will respond with a 1 code and will not block the whole flow.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.