SilentVoid13 / Templater

A template plugin for obsidian
https://silentvoid13.github.io/Templater
GNU Affero General Public License v3.0
3.32k stars 199 forks source link

Expand metadata in space - Geolocation coords support request #1371

Open Tylannn opened 6 months ago

Tylannn commented 6 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

No.

Describe the solution you'd like A clear and concise description of what you want to happen.

Like any other tp usage, convert <% tp.coord.current("format") %> to coords in ISO 6709 format.

For example: <% tp.coord.current("±DD.DDDD±DDD.DDDD") %> will be +12.345-098.765.

Geolocation_API should be useful, and this is a minimal practise from W3C school:

<script>
const x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude +
  "<br>Longitude: " + position.coords.longitude;
}
</script>

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Not yet.

Additional context Add any other context or screenshots about the feature request here.

This feature might be very useful, when people getting old and reading their notes or dairy, a geolocation coords will bring kind of memory. OpenStreetMap's API could convert coords to specific name.

McGlear commented 5 months ago

If the documentation around accessing the GPS location within Obsidian using the map view plugin is still up to date, then Obsidian does not support accessing device location. Map view offers a workaround using a helper app. I would consider such approaches out of scope for Templater. However, I would assume you should be able to access Map View functions from within Templater scripts, as long as the desired functionality is provided as an Obsidian command. Have you tried that?

Zachatoo commented 5 months ago

In case it isn't clear on how to execute an Obsidian command.

You can get a list of the command IDs by opening the dev console (CMD Shift I) and typing app.commands.commands into the console.

This example will run the “Daily notes: Open today’s daily note” command.

<%*
app.commands.executeCommandById("daily-notes");
%>
Tylannn commented 5 months ago

I checked official document. It seems there's no way for add-ons to get geolocation or ask for it. And, yeah, access outside API is to much for templater.

May we could model obsidian leaflet's way? Let user input coords manually, most people don't change location frequently. But I'm not sure if it's worthy, too much input box looks messing.

And, apparently, user script can do this.