Search code examples
javascriptandroidgeolocationwikitude

Getting user location using wikitude SDK for Android


I'm currently using wikitude sdk 4.0 for android and trying out the the sample of Multiple POIs in my app. https://github.com/Wikitude/wikitude-sdk-samples/tree/master/3_PointOfInterest_3_MultiplePois

I got it instantiated but stuck with user location.

I don't understand how the user's location is pulled by this Javascript https://github.com/Wikitude/wikitude-sdk-samples/blob/master/3_PointOfInterest_3_MultiplePois/js/multiplepois.js


Solution

  • The "AR.context.onLocationChanged = World.locationChanged;" in JS does the magic.

    After this line is executed the 'World.locationChanged' (or any other given) function is fired on every Android/iOS native call of the architectView's setLocation is executed.

    Check out the LocationProvider-implementation in the Sample Application for a very basic approach. For state-of-the-art location fetching I recommend you to have a look at Google's Location Strategies.

    Kind regards.