Start a new topic

setLocation from flutter

I am trying to adjust one of the provided samples so it uses the device's gps location. To achieve that, I have implemented a third party plugin, which is providing the necessary arguments. Yet I do not know how to exactly call the setLocation-method from within the flutter app.


I have not found a thread tackling that problem, if you have one in mind I am happy to have a look since I am sure that I am not the first to have an issue with this.


Thanks in advance!


 Furthermore the message "Trying to find out where you are" keeps showing up, though the third party plugin doesn't seem to have any problems locating the device.

Hi,


The message 'Trying to find out where you are' indicates that you don't have a GPS fix yet. As long as this message is shown, we can't distinguish where you are and can't display the POIs. If the messages comes and goes, this indicates that the signal is not stable.


For the compass issue. Can you please try with the device and a compass app to see how the compass is behaving in the location you're testing. If the values move there as well this is another indication that the compass values are not as accurate as needed.


Thx and greetings

Nicola

The message 'Trying to find out...' is shown constantly, while other apps with GPS work fine. 

Same for the compass, other apps don't seem to have a problem.


Can I provide you with some other information that might help finding the error?

I think I have misunderstood the Location Provider section profoundly.

I thought I'd only have to pass the gps data into

this.architectureWidget.setLocation(),

which I did with help of the flutter plugin 'location'.


Is it correct that I have to implement this Location Strategy somewhere in my flutter app?


Thanks!

As this thread is already very long - can you please recap your latest issues with further details on the values, how you're doing the Flutter location handling,...


Thx and greetings

Nicola

Below you can see the output of the app, lines starting immediately with the coords are from flutter, the ones starting with CONSOLE from the sdk.
I am generally startled by the accuracy and the fact that the locationChanged of the SDK is called independently of the setLocation in flutter.

I hope you understand what I mean, thanks for your patience

 

 lati -15.7824589 - long 128.7346556 - alti 0.0 - accu 82.5
 lati -15.7816352 - long 128.7409094 - alti 0.0 - accu 2700.0
 [INFO:CONSOLE(99)] "sdk: lati -15.782459 longi 128.73465 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.782459 longi 128.73465 alti -32768 accu 1"
 lati -15.7816352 - long 128.7409094 - alti 0.0 - accu 2700.0
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 lati -15.7816352 - long 128.7409094 - alti 0.0 - accu 2700.0
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.780281 longi 128.74156 alti -32768 accu 1"
 lati -15.7802814 - long 128.7415639 - alti 0.0 - accu 1000.0
 [INFO:CONSOLE(99)] "sdk: lati -15.780281 longi 128.74156 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 [INFO:CONSOLE(99)] "sdk: lati -15.781635 longi 128.74091 alti -32768 accu 1"
 lati -15.7816352 - long 128.7409094 - alti 0.0 - accu 2700.0

 

 

Hi,


So this message is shown in the unchanged SDK sample app? Or did you change something? If you changed something, please also have a look at the unchanged sample app.


Do you get a GPS position on this device if you try a GPS status app?


Thx and greetings

Nicola

Hi Hendrik,


You can find details on Flutter Location handling here:

https://pub.dev/packages/background_location_updates


I hope this helps. Greetings

Nicola

 When you say SDK sample app, do you mean e. g. the sample '09_ObtainPoiData_2_FromLocalResource'? Yes, that is unchanged.


If you mean the actual flutter code, here is it:

import 'package:flutter/material.dart';
import 'package:augmented_reality_plugin_wikitude/architect_widget.dart';
import 'package:augmented_reality_plugin_wikitude/startupConfiguration.dart';

import 'package:location/location.dart';

class Ar extends StatefulWidget {
@override
_ArState createState() => _ArState();
}

class _ArState extends State<Ar> with WidgetsBindingObserver {
ArchitectWidget architectWidget;

String _licenseKey =
'takenoutforobviousreasons';

StartupConfiguration startupConfiguration = StartupConfiguration(
cameraPosition: CameraPosition.BACK,
cameraFocusMode: CameraFocusMode.CONTINUOUS,
cameraResolution: CameraResolution.AUTO);

@override
Widget build(BuildContext context) {
return Scaffold(appBar: AppBar(), body: Container(child: architectWidget));
}

@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);

architectWidget = new ArchitectWidget(
onArchitectWidgetCreated: onArchitectWidgetCreated,
licenseKey: _licenseKey,
startupConfiguration: startupConfiguration,
features: [
"image_tracking",
"geo"
], //image_tracking, object_tracking, geo or/and instant_tracking
);


}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
switch (state) {
case AppLifecycleState.paused:
if (this.architectWidget != null) {
this.architectWidget.pause();
}
break;
case AppLifecycleState.resumed:
if (this.architectWidget != null) {
this.architectWidget.resume();
}
break;

default:
}
}

@override
void dispose() {
if (this.architectWidget != null) {
this.architectWidget.pause();
this.architectWidget.destroy();
}
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

Future<void> onArchitectWidgetCreated() async {
this.architectWidget.load(
"wikitude_samples/09_ObtainPoiData_2_FromLocalResource/index.html",
onLoadSuccess,
onLoadFailed);
this.architectWidget.resume();
}

Future<void> onLoadSuccess() async {
print('succeeded');
_setupLocation();
}

Future<void> onLoadFailed(String error) async {
print('failed');
}

void _setupLocation() async {
var location = new Location();


location.onLocationChanged().listen((LocationData loca) {
print(loca.latitude);
print(loca.longitude);
print(loca.altitude);
print(loca.accuracy);

this.architectWidget.setLocation(
loca.latitude,
loca.longitude,
100, //also tried with loca.altitude
0); //also tried with loca.accuracy
});
}
}


Thanks in advance!


That does not seem suitable as I would have to use a deprecated Flutter SDK:

Because wikitude depends on background_location_updates >=0.0.2
which requires SDK version >=1.19.0 <2.0.0, version solving failed.


Do you see this being updated in the near future?

Do you have any possible alternatives in mind?


Hi,

just an update:

It kind of works with the plugin location 2.3.5 (I can go past a POI, but it is not scaling yet as I am moving further away), though I am still told that the SDK is trying to find me.

The accuracy is down to 5 metres.


Hi Hendrik,


Thx for your feedback and the accuracy. It sounds to me that you solved the problem with the plugin version. For the scaling: did you go just some meters or further. The scaling would only show for POIs that are further away.


Thx and greetings

Nicola

Hi Hendrik,


First of all, sorry for the late response.


The onLocationChanged callback is always being called by our SDK in the geo examples, but once the setLocation method is called by the Flutter code, we set the useCustomLocation parameter to true, so it doesn't update the location by its own. If you put the CONSOLE log inside the if, you will see that it is not called anymore.


On the other hand, we will check the altitude and the accuracy problem. In the meanwhile, you could test an altitude greater than 0.0 until the problem is fixed.


Thanks,


Aitor Font.

Hello Nicola,


I thought I had solved the whole issue. However, I am still confused because, eventhough I am providing the location with the plugin mentioned above, the locationChanged-method of the SDK is being called multiple times with unrealistic values for altitude and accuracy. Furthermore, the locationChanged-method is called many times more than I am invoking the setLocation-method from within the flutter plugin.


I hope you understand what I mean and anyway, thanks in advance


Login or Signup to post a comment