Start a new topic

How to retrieve the user's current location?

How to retrieve the user's current location?


Is it possible to retrieve the user's current location from the front end using the architect.js?

Have a look at AR.context.onLocationChanged. You can set any callback function to this trigger and get notifications whenever the location changes.

e.g

AR.context.onLocationChanged = function(latitude, longitude, altitude, accuracy){
  //...
}

 

Keep in mind that it will be called on all successive location changes as well.

How do I retrieve the user's current location out of location context (it is not called beginning of the script execution)?

What platform are you using it on? If you are using Android make sure you have a location provider that updates the location via ArchitectView.setLocation().

Addtional read on location handling on android:


http://stackoverflow.com/questions/6181704/good-way-of-getting-the-users-location-in-android

http://developer.android.com/guide/topics/location/strategies.html


On iOS the callback function is called whenever the first location is avaiable. Depending on your current environment (indoor, outdoor, wifi available, gps signal strong etc.) this might not immediately be available.
Login or Signup to post a comment