TypeError: Cannot read property 'getCurrentPosition' of undefined
See original GitHub issueAfter all setup I have this issue::
> TypeError: Cannot read property 'getCurrentPosition' of undefined
> at Object.getCurrentPosition$ (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:162211:33)
> at tryCatch (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21370:19)
> at Generator.invoke [as _invoke] (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21543:24)
> at Generator.prototype.(anonymous function) [as next] (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21413:23)
> at tryCatch (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21370:19)
> at invoke (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21446:22)
> at blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:21474:13
> at tryCallTwo (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:20708:7)
> at doResolve (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:20872:15)
> at new Promise (blob:http://localhost:8081/0786bd13-e17c-404e-8e19-b46bdfbaf7f3:20731:5)
Steps I have followed::
After these I have installed “react-native-geolocation-service” package Link this package I have followed all the Android settings. Import in file like this:: import Geolocation from “react-native-geolocation-service”; Function where I used it::
getLocation() {
Geolocation.getCurrentPosition(response => {
console.log("geo response = ", response);
if (response && response.coords) {
console.log("geo res true");
this.saveLocationLogs(response.coords);
}
},
(error) => {
console.log("Error geolocation");
this.onGeolocationErrorOccurCallback(error);
},
GeolocationOptions
).catch((error) => {
console.log(error);
});
}
There is a TypeError: cannot read property getCurrentPosition of undefined. still I am not able to get my current location?? Why this is happening? Please suggest me a solution.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Cannot read property getCurrentPosition of undefined · Issue ...
I have tried everything I can and I can't seem to find a solution. when I'm trying to get current location, I get...
Read more >javascript - Uncaught TypeError: Cannot read property ...
jquery-3.3.1.min.js:2 Uncaught TypeError: Cannot read property 'getCurrentPosition' of undefined at geoLocationInit (google.js:8) at ...
Read more >Getting a "read property 'coords' of undefined"
I tested the code and it works, but there is an issue: the second parameter to getCurrentPosition should be a reference to a...
Read more >Geolocation.getCurrentPosition() - Web APIs | MDN
If set to 0 , it means that the device cannot use a cached position and must attempt to retrieve the real current...
Read more >The Geolocation API / Ben Pyrik - Observable
"By default, getCurrentPosition() tries to answer as fast as possible with a low ... TypeError: Cannot read properties of undefined (reading 'longitude').
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
fuck u github…u dont have solutions for our questions
Check These lines added in your MainApplication.java
import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
new RNFusedLocationPackage() in protected List<ReactPackage> getPackages() method
It fixes my issue