question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'getCurrentPosition' of undefined

See original GitHub issue

After 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:closed
  • Created 5 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

35reactions
NasirRazaChangezicommented, Aug 3, 2019

fuck u github…u dont have solutions for our questions

2reactions
mehrankhandevcommented, Aug 20, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found