Insert physical geographical location in a template

HI. Tried searching the forum but couldn’t find any answers. Say for a daily journal template, besides the date and time, I would also like to insert my current geographical location as well. Is that possible? Thanks in advance!

1 Like

The Templater community plugin allows you to feed your templates with the result of any shell command.

For example, on a Mac,

curl https://freegeoip.app/json/ | python3 -c "import sys, json; r=json.load(sys.stdin); print(r['region_name'] + ', ' + r['country_name'])"

will return your_city, your_country. You could even manipulate the response in some other way, or build a google maps URL. However, it won’t go any more detailed than that, because it relies on IP location.

If you need a GPS-like “exact location”, that’s probably also possible, but you’ll have resort to another kind of API provider like here.com, and the scripting will be harder to put together.

3 Likes

City and country is plenty enough for a daily journal entry. Just something to help reference where notes were taken for future reference. Will try this! Thanks!

1 Like

The script works like a charm and is exactly what I needed. But can’t seem to get templater to insert it :joy: I am able to get it to insert the dates, time etc as needed but it won’t render the location.

I have tested it on both my Macs and it worked. Can you post your template?

Thank you @macedotavares. This is the sort of personalization that makes me smile when I open up my daily note.

figured it out. It works when I use the hotkey by templater to manually insert the template. But now there’s another issue. I am using Calendar and when I click on the date or the hotkey, it creates a daily note and uses the “daily note template” i created and that works great. But it won’t render {{tp_location}} but the rest that is from system like {{date:DD MMMM YYYY}}, {{date:dddd}} will render. That is when I create a daily note.

If I use the templater hotkey to insert a template manually, the {{tp_location}} will work, but the others won’t work. Does that make sense? How can I do this easily :joy:

Basically, I just want to create daily notes easily based on a template that is created either when I click on the date in calendar or the hotkey assigned.

The Calendar and the Templater are two distinct community plugins and not meant to work together. I think your best bet would be to stick to Templater, possibly fixing some placeholders according to its documentation.

I can’t help you with this right now, but if by Monday you’re still having trouble, I’ll be glad to assist you.

Working like a charm now. Thanks for all your help!