Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mdg:location ~ Geolocation.currentLocation() returns null even when location is available through browser navigator.geolocation.getCurrentPosition #63

Closed
hems opened this issue Jun 3, 2015 · 4 comments

Comments

@hems
Copy link

hems commented Jun 3, 2015

The first time i install my app the application is getting an onError "TIMEOUT" and don't try to fetch the position anymore.

The side effect is that Geolocation.currentLocation() will be null even after the user has authorized the location service, therefore making the location available through: navigator.geolocation.getCurrentPosition( my_callback )

related to: #62

@hems hems changed the title mdg:location mdg:location ~ Geolocation.currentLocation() returns null even when location is available through browser navigator.geolocation.getCurrentPosition Jun 3, 2015
@skhan02
Copy link

skhan02 commented Oct 25, 2015

You have to call the the currentLocation() inside of a helper or autorun. Check the solomo example on the github page!

@sunlee-newyork
Copy link

@skhan02 worked for me, thank you!

@rashmimhatre100
Copy link

rashmimhatre100 commented Aug 11, 2017

Working with meteor react getting the same problem i.e null.

handleMapOptions() { Tracker.autorun(() => { var latLng = Geolocation.currentLocation(); var latLng1 = Geolocation.latLng(); // Initialize the map once we have the latLng. console.log(latLng); console.log(latLng1); });

if (GoogleMaps.loaded()) {
  return {
    center : new google.maps.LatLng(37.779161, -122.435228),
    zoom   : 12,
  };
 }
}

@StorytellerCZ
Copy link
Collaborator

For React you should use the useTracker hook or withTracker HOC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants