Macro: Add location long-lat from address
This macro asks you for an address, looks up its coordinates, and adds a location property with [lat, long] as its value to the note you have open. It is especially useful for the Obsidian Map View plugin, which reads that property to place notes on a map.
Before you start
Section titled “Before you start”- The MetaEdit plugin must be installed and enabled. This macro uses MetaEdit’s
createYamlPropertyfunction to write the property.
- Grab the script from this page. You can either click the download link, or copy the file contents and save them as
getLongLatFromAddress.js. The.jsextension is essential. - Save the file anywhere in your vault (not inside the
.obsidianfolder). For a fuller walkthrough with video, see the guide to installing user scripts. - In QuickAdd settings, click Add Choice, select Macro, and give it a name (I call mine
Mapper). This creates a Macro choice and opens the Macro Builder. If you close the builder, click the gear (Configure) button on the choice in the list to reopen it. See the Macro choice docs for a full walkthrough. - In the Macro Builder, place your cursor in the User Scripts field to bring up a suggester, pick
getLongLatFromAddress.js(or click Browse to select the file), and click Add. It should appear as the first command. - Close the QuickAdd settings.
What you get
Section titled “What you get”Run the macro with the QuickAdd: Run command in the command palette and pick your choice. Enter an address, and QuickAdd adds a location property to the active note whose value is [lat, long] for that address.
