Access location data

Is it possible to access location data from Unity?

Input.location.Start(); doesn't seem to kick in after being called - status keeps the value of LocationServiceStatus.Initializing.

I did add the appropriate permissions and requested them in runtime:

I know that ML2 doesn't have GPS receiver, but it does have an option to select the mock location app within Developer options (settings) thus I figured the Location API should be accessible.

Any luck with location data on ML2 anyone?

Hi @rafal.legiedz,

I have reached out to our team regarding this issue and I will report back as soon as I learn more.



That would be most helpful. Thanks.

Were you able to select which app you wanted to use as a Mock Location provider in the System Developer Settings? Are you using an existing provider or creating a custom one?

I was able to set it to Trimble Mobile Manager (third-party):

@kbabilinski any news on that?

Hi @rafal.legiedz,

Could you please provide a few details to help us get you a solution?

  • Unity Editor version
  • ML2 OS Version
  • ML SDK Version
  • Development OS (e.g. Mac, Windows)


  • Unity version: 2022.3.18
  • ML2 OS version: 1.5.0
  • ML SDK version: 2.0.0
  • Development OS: MacOS

@etucker @kbabilinski here's the repo with a sample app, if run on ML2 one could see in logcat that LocationService ain't initializing within a given 20s timeout

Hi @rafal.legiedz,

Thank you for providing this sample project. I will be sure to take a deeper look.

1 Like

What is your GNSS Receiver set as in your Trimble Mobile Manager app?

Hi @rafal.legiedz,

I was able to mock location using a different third-party application. Can you verify that the Trimble Mobile Manager is reporting the correct values here?

@etucker I had paired Trimble Catalyst here for a moment, but I couldn't proceed with that approach as there are other issues regarding Trimble Mobile Manager on ML2 (basically it requires Chrome to be installed in the system).

But anyway, which app did you manage to app location data with? Does LocationService work for you from within the ML2 app?

We tested the “Fake GPS location” app but the following app may work and it’s source code is available: GitHub - mcastillof/FakeTraveler: Fake where your phone is located (Mock location for Android).

When looking for a Mock location provider, it is important to find one that does not require google play services.

@kbabilinski thanks for sharing this. Do you happen to have .apk for FakeTraveler that I could drop to ML2 and test? Thanks!

@kbabilinski ok, I've managed to build and instal the .apk on ML2. I set the location and then tried my app I shared here earlier (the Unity location service one).

Looked into the logs and still the Location Service keeps failing to initialize.

How did you test it?

@kbabilinski I've tested the app suggested by @etucker Fake GPS location - Apps on Google Play and it made the location service initialize and report the faked location.

Thus I believe there need to be a working mock location data app installed and running on ML2 for the Unity's Location Service to initialize and properly report data.

I think that concludes the issue (at least for now). Thank you for your support in that matter! Now I need Trimble Mobile Manager to work - but it requires Chrome for configuration :frowning:

P.S. I've created a separate thread regarding Chrome.

Is there no (wifi-based) coarse location on the ML2? I'm using plain Android (through .NET) and use LocationManager.RequestSingleUpdate() but no location update ever seems to come. The same code runs fine on a Meta Quest 3 and provides a correct lat/lon location in seconds.

Hmm, conflicting info, as Magic Leap 2 Devices | Magic Leap says:

Location Detection and Use

Unlike Magic Leap 1, Magic Leap 2 devices do not attempt to derive any information regarding your location, nor does Magic Leap currently provide any functionality designed to enable an enterprise to determine the location of a Magic Leap 2 device user. However, Magic Leap 2 devices may be attached or paired via Bluetooth to peripheral devices which provide location services.

But then there's also Location Detection and Use | Magic Leap (which I had found earlier and assumed to be correct), which says:

Location Detection & Use

When you connect your Magic Leap device to a Wi-Fi network, Magic Leap systems will attempt to derive your precise location information (latitude and longitude coordinates) from information collected about your device and nearby Wi-Fi routers, including MAC addresses, detected from the Wi-Fi networks around you, using Google’s Geolocation API service. Magic Leap may also collect your approximate location information (including your continent, country, city, and postal code) using your IP address. Your device’s location can only be detected when the device is connected to the internet. Magic Leap enables apps to query your Magic Leap device for location information with your permission.

Is the latter out of date and incorrect?

Location Detection and Use | Magic Leap The data here refers to the Magic Leap 1. The Magic Leap 2 does not have built-in GPS capabilities. If you are to retrieve GPS data on the ML2 headset, you would have to use an external device. Magic Leap never stores or uses your location data.