Skip to content

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.

  • The MetaEdit plugin must be installed and enabled. This macro uses MetaEdit’s createYamlProperty function to write the property.
  1. 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 .js extension is essential.
  2. Save the file anywhere in your vault (not inside the .obsidian folder). For a fuller walkthrough with video, see the guide to installing user scripts.
  3. 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.
  4. 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.
  5. Close the QuickAdd settings.

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.

Demo