Hello. I created an application that uses the location sensor component.
I wish to send the latitude and longitude of my phone using the location sensor when a button is clicked. Instead it returns a zero value and is quite very unhelpful because it causes a lot of errors.
That is because you haven’t a location yet. That depends on where you are, how you get your fix. The lng and lat are only available after the locationsensor has found your location. So it might take some time, sometimes up to 30 seconds or longer depending on the conditions.
How can I improve my code to not send the zero values and wait for the real location instead? and also, it gives a kilometer away incorrect data. i can’t think of any code to improve it. Any help will be so much appreciated!
I tried using that but it does not fit my system functionality. (or maybe I did it wrong?)
I really want to have a location data only and only when the button is clicked.
@Peter is right, take time get location.
everything depends how to the set of the locations on smartphone.
1 > Gps, wifi and mobile data
2 > Wifi and mobile data
3 > Only GPS