Start a new topic

Custom Gps position

Hello !


I'm using the Javascript SDK on iOS.


I want to provide custom GPS position to the Wikitude SDK but i can't figure how to use setUseInjectedLocation: and injectLocationWithLatitude...


Right after creating WTArchitectView and WTNavigation :

 [self.architectView injectLocationWithLatitude:48.853 longitude:2.35 accuracy:1.0];

 [self.architectView setUseInjectedLocation:YES];


 I set up this callback in js :

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


And i keep getting position update but not the one i passed using injectLocationWithLatitude:longitude:accuracy


Hello Quentin,

Please refer to the documentation provided regarding setUseInjectedLocation and injectLocationWithLatitude.


I believe that this is a good place to start in order to collect the information you need. In general, on iOS, you can inject the location by setting the seUseInjectedLocation function to true and inject it with the function injectLocationWithLatitude. Don't forget that you really have to walk some meters that you notice a location change.


Hope that helps,

Eva

Hello eva,


thanks for your reply.

I already read the documentation...


Should i call useInjectedLocation before of after injectLocationWithLatitude?

If i call it only once my location is going to be "freezed" to the one i provided, right ?


Hi Quentin,

Maybe the code below could help you understand

 

- (void)injectLocationWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude altitude:(CLLocationDistance)altitude accuracy:(CLLocationAccuracy)accuracy
{
    [_architectManager injectLocationWithLatitude:latitude longitude:longitude altitude:altitude accuracy:accuracy];
}

- (void)injectLocationWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude accuracy:(CLLocationAccuracy)accuracy
{
    [self injectLocationWithLatitude:latitude longitude:longitude altitude:wikitude::sdk_core::impl::LocationInfo::UnkownAltitude accuracy:accuracy];
}

- (void)setUseInjectedLocation:(BOOL)useInjectedLocation
{
    [_architectManager setUseInjectedLocation:useInjectedLocation];
}

- (BOOL)isUsingInjectedLocation
{
    return [_architectManager isUsingInjectedLocation];
}

 

 Hope that helps,

Eva

 

No sorry,


Do you have any example or code sample using  codecode injectLocationWithLatitude ?

Hi Quentin,

Apart from the links to our Reference API and the code I already provided, there is nothing more that I could share with you.

Thanks
Eva

 

Hello,


I am sorry but your answer does not help me.

Before buying your SDK I want to make sure I can use it correctly.

Can you please help me on this, I have ready many times your documentation and it does not provide the right information. 

You can  also find the question on StackOverflow : http://stackoverflow.com/questions/43707278/inject-location-with-wikitude-ios-javascript-sdk


Best regards

Hello,



The code you posted is fine and would have worked just fine in previous SDK versions.


We recently changed the lifetime of some internal services of the SDK; specifically when they are started and stopped. I believe this is what's causing the injection to fail for you.


Specifying and using an injected location will only work when a particular one of these internal services is currently running. I believe this behaviour is unintended and requires fixing.


For you, however, the only viable workaround is injecting the location at a later point; after the world has been loaded and fully evaluated.


My suggestion would be to call into the native code from your javascript world to inject the location then and there.


I tested this by injecting the location upon screen orientation change. If you do the same, you should find your code to be working.



- Daniel

Login or Signup to post a comment