83
Views
14
Comments
[Location Plugin] GetLocation returning successfully with (0, 0) coordinate
location-plugin
Mobile icon
Forge asset by OutSystems
Application Type
Mobile
Service Studio Version
11.54.38 (Build 63033)

Hello,

We are experiencing issues using the GetLocation plugin with our native mobile application on an iOS device, it is unclear how it works on Android at the moment. It works fine and returns the correct position during our OfflineDataSync flow, but now we are trying to implement it in an OnClick and it returns (0, 0) every time. The GetLocation action appears to be completing successfully and is not returning a timeout message. We are using MABS 9 on a iPhone X with iOS 16.7.2. The GetLocation timeout is set to 30000 ms, and I have tried setting EnableHighAccuracy to False but that didn't help. The Location should be near (39.622, -104.897). I have confirmed that Location Permissions are enabled on my device and for the specific application. I have attached a screenshot of the OnClick logic flow where the GetLocation is failing every time. Please advise.

Thanks,
Charlie Highum


Screenshot 2024-01-04 094238.png
2024-05-08 06-29-37
Prince Aadil Khan Panwar

Hi Charlie Highum,


i tried with location i got the same 0,0 attaching the oml if you want to check. instead of using location plugin.

use this simple javascript

if (navigator.geolocation) {

  navigator.geolocation.getCurrentPosition(function(position) {

    const latitude = position.coords.latitude;

    const longitude = position.coords.longitude;

    console.log(`Latitude: ${latitude}, Longitude: ${longitude}`);

  });

} else {

  console.log("Geolocation is not supported by this browser.");

}

hope this will help

Thanks

Prince

getLocation.oml
UserImage.jpg
Charlie Highum

I'm confused, what is the attached OML supposed to be showing me? It does not appear to have the simple JavaScript code implemented, and that JavaScript code is not working in my application either as it also returns (0, 0) coordinates.

2024-05-08 06-29-37
Prince Aadil Khan Panwar

In attached oml the location plugin is used but it's not working the same returning value 0,0. I have given you javascript which you can use for get the location instead of plugin. Make changes as per your requirement. Sorry for the confusion.

UserImage.jpg
Charlie Highum

Unfortunately the JavaScript is also returning a 0,0 value, so it doesn't seem like a viable solution in this case.

2024-05-08 06-29-37
Prince Aadil Khan Panwar

Open this html code and take javascript from here and implement into outsystems

https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation

I tried and it is returning values

UserImage.jpg
Charlie Highum

I have tried playing around with your original code, that link, ChatGPT, and several other sources and everything is returning 0,0 coordinates. Do you have any idea why this might be happening?

2024-05-08 06-29-37
Prince Aadil Khan Panwar
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

for you, it doesn't mean it works for the original poster of the question.

2024-05-08 06-29-37
Prince Aadil Khan Panwar

as @Toto adviced, fixed oml i am attaching, and yes it is giving the Location cordinates


getLocationfixed.oml
UserImage.jpg
Charlie Highum

@Prince Aadil Khan Panwar 

Apologies for the confusion, the W3Schools demo works for me as well, but when I transfer that exact code into my application it returns 0,0. Are there any required dependencies or scripts I might be missing?

Thanks

2021-01-04 08-13-48
Toto
 
MVP

Hi Charlie,

I tried to replicate your logic

With Timeout 30000ms and EnableHighAccuracy False

It is work on my Android.

What I can suggest is :
1. Update the Location plugin (there is new version on 20th Dec 2023, version 5.2.1)
2. Try to open map application on your iphone then back to your app and check the location (I often got this case on Chinese Android device (not mainstream brand), that the GPS got stuck and need to open GoogleMap app to "unstuck" it)

3. Connect your device to mac, and open safari, there is feature to get the device log (I am not a mac user, but my team member do this to debug ios device), similar like connecting android device to laptop, then open chrome : chrome://inspect/#devices (for android need to enable USB debugging)

4. Check the iphone permission for the GPS and app (https://support.apple.com/en-us/102647#:~:text=Go%20to%20Settings%20%3E%20Privacy%20%26%20Security%2C%20then%20select%20Location%20Services,Precise%20Location%20on%20or%20off.)


UserImage.jpg
Charlie Highum

@Toto 

Thank you for the suggestions. The GetLocation plugin has already been updated to the most recent version and all of my permissions are setup correctly. The GetLocation plugin is working in the app on my device in the OfflineDataSync flow, but for some reason is returning 0,0 in the OnClick action.

I will work on getting the device log through safari and see if I find anything there.

Thanks

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Charlie,

You have confirmed it works on an Android, but not on an iOS device.

Can you try the following actions to narrow the problems space:

  1. Try it on another iOS device
  2. Try it on another iOS device with an older iOS version
  3. Try it after building a version of the iOS version using MABS8

Regards,

Daniel

UserImage.jpg
Charlie Highum

I am sorry for the confusion. We have not tested on Android yet, I am working on getting other team members to test with different devices. 

It doesn't make sense that the GetLocation plugin works when called through the OfflineDataSync and is returning the correct location, but then returns 0,0 without a failure message when using it in an OnClick. Can you think of any possible workarounds here? 

I have tried to implement the custom JavaScript @Prince Aadil Khan Panwar recommended, and it worked in the browser in the W3Schools demo, but then when I transferred it to my app it also returns 0,0.

I will work on regenerating the app with MABS 8 to test that option as well. Are there any potential consequences of using MABS 8 vs 9?

Thanks

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.