Mobile: Can Obsidian API provide current geo location (GPS) on Android/iOS?

Use case or problem

Easily get at the current geo position (GPS) on a mobile device that runs Obsidian.
Mainly to update a “current location” note, for use with the Obsidian Leaflet maps.

Proposed solution / current workaround

On my laptop, I use Templater to update a “Current Location” note by calling a Python script that evaluates my current geo location (from the laptop’s GPS or IP address).

I’d very much like to see that on the mobile version, so I could have a “live view” of my Obsidian Leaflet maps. It’s of course not that easy on a smartphone: Users have to consent reading the GPS location, and I wonder if it’s available in Typescript/Javascript, instead of running external code.

So the best bet would be that the Obsidian API could support that functionality and provide some means for a plugin (or JS code) to read out the location data, i.e. at least latitude and longitude (WGS 84), maybe even elevation (meters).

Thus, plugins like Obsidian Leaflet maps could use it directly, and notes using Templater and/or Dataview scripting could also use it.

Is that possible? Or planned?

I feel this could be a real cool feature.

Related feature requests (optional)

4 Likes

There are some NPM packages dealing with geolocation. E.g., geolocation - npm

I don’t know what would happen if a plugin tried to use them on mobile, though. I imagine it would just fail silently…

Looks like Capacitor has an official geolocation plugin. Would probably be better to use that for mobile.

On desktop, the Google API key has to be set and have Geolocation permissions in Electron to use Chromium’s geolocation API. See here.

1 Like

<rant>

So on Android you have to get a Google API key for a function that the phone’s hardware provides.

Ridiculous scheme, eh? Getting the data from almost everyone for free and making them pay (for many requests) to be able to access their own data!

</rant>

1 Like