Leaflet bases

by Sara Lilith Slootmaker
5
4
3
2
1
Score: 40/100

Description

Interactive map view inside your Obsidian bases.

Reviews

No reviews yet.

Stats

14
stars
6,044
downloads
3
forks
185
days
56
days
96
days
17
total PRs
2
open PRs
2
closed PRs
13
merged PRs
13
total issues
7
open issues
6
closed issues
73
commits

Latest Version

3 months ago

Changelog

Added

  • Map context menu: Right click a position on the map to add a marker or update the map. (#17)
  • Marker context menu: Right click a marker to update or remove a marker. (#17)
  • Removed the map "copy tool" and added the lost functionality to the map and marker context menus (#17)
  • "Create note here" map toolbar tool: click a spot on the map to create a new note (respecting the vault's "Default location for new notes" setting) or add the marker to an existing note, from a single field. (#14)
  • The context menu's "Add marker to note" now uses the same new-or-existing-note flow as the toolbar tool, replacing the old new-note-only flow. (#14)
  • Pick a marker's map and coordinates directly from the map itself: the marker property's '+' button now lets you pick which Leaflet map view a marker belongs to (when the vault has more than one), then click on that map to set its coordinates, instead of typing them by hand. (#15)
  • The marker modal gains an "Open map" button that jumps to the note's Leaflet map view, and a live preview of the currently selected icon. (#15)

Fixed

  • MarkerModal no longer crashes when a subclass (e.g. the note-picker modal) reads a constructor argument while building its settings, by moving settings construction to Obsidian's onOpen() lifecycle hook instead of the constructor. (#14)
  • The map's background image can no longer be dragged out via the browser's native image drag-and-drop. (#14)
  • Right-clicking a marker no longer re-centers the map on it. (#14)
  • The marker-add map/coordinate picker now also finds Leaflet map views defined in bases embedded as code blocks in markdown notes, not just standalone .base files. (#15)
  • Markers now properly reset after the base view is changed ([#12])
  • The note-picker modal now crashes gracefully when obsidian is unable to deserialise the user's base formula (#23)

README file from

Github

Leaflet Bases

preview

This plugin for Obsidian adds a new bases view: 'Leaflet Map' and a new type of property: 'marker'

Please report any issues you encounter here.

Leaflet bases was developed for three reasons:

  • To leverage the versatility of Obsidian bases
  • Marker data is part of the note it belongs to, not of the map it is shown on
  • To have your maps be available in your online garden using Quartz, there is a separate Quartz plugin for that.

For use with Quartz you'll need the appropiate Quartz plugin. Quartz v5 supports bases but is still in open beta, there is also a Quartz plugin version that supports Quartz v4.

Usage

You can find an example vault here.

Adding a map

Using configurations
  1. First you need a base and add a 'Leaflet Map' view. add map
  2. Change the settings as you wish.
Using a code block

You can also embed the base:

```base
views:
  - type: leaflet-map
    name: Map
    mapName: test
    image: assets/Locke.png
    height: 400
    minZoom: -1.5
    maxZoom: 2
    defaultZoom: -1.5
    zoomDelta: 0.25
    scale: "0.2"
    unit: km
```
Setting What it does
Layout type The type of base, don't change this (from Obsidian bases)
- name What the view is called (from Obsidian bases)
Image image The image the map should show. It also accepts wiki links.
Map name mapName Optional identifier for the map. Useful if you want to reuse a note across several maps
Default zoom defaultZoom The zoom value the map opens with
Minimum zoom minZoom How far you can zoom out
maximum zoom maxZoom How far you can zoom in
Zoom stepsize zoomDelta How much you zoom
Scale scale How much to scale the result of the measure tool
Unit unit The unit the measure tool uses (think km, mi, hours)

Technically only 'type', 'name', and 'image' are required for the map view to work. However you'll likely end up using most of the other settings.

Instead of setting mapName in the base, you can also use a bases filter;

views:
  - type: leaflet-map
    name: Map
    image: assets/Locke.png
    filters:
      and:
        - '!marker.filter(value.mapName == "MAP_NAME").isEmpty()'

Adding a marker

Using UI
  1. Add a new marker property to the note you want to have a marker. add marker property

    Ensure the property is of the 'Marker' type!

    set marker property type

  2. Add a marker using the '+' button that appeared. If the vault has more than one Leaflet map view, pick which one the marker belongs to, then click on that map to set the marker's coordinates. Fill in the form in the modal and click 'Create marker'. add marker modal
  3. You can add more markers using the '+' button, edit markers by clicking the tags, or remove them using the 'x' buttons. edit marker modal

The first time you use the plugin, Obsidian might not recognise the marker property and you will not see the '+' button

Using the map
  1. Enable the "create note" tool in the plugin settings (Settings → Leaflet bases → Enable create note tool).
  2. Select the "Create note here" tool in the map's toolbar and click a spot on the map.
  3. Fill in the form. In the note name field, either type a name to create a new note there, or pick an existing note shown in the base to add the marker to that note instead.
  4. New notes are created at your vault's default location for new notes. Be aware that if Obsidian is unable to deserialise your formula this can fail.

You can drag markers using the drag tool. Be sure to enable it first (Settings → Leaflet bases → Enable drag tool).

Using the context menu
  1. Right a spot on the map.
  2. Select Add marker to note.
  3. Fill in the form. In the note name field, either type a name to create a new note there, or pick an existing note shown in the base to add the marker to that note instead.
  4. New notes are created at your vault's default location for new notes. Be aware that if Obsidian is unable to deserialise your formula this can fail.

You can edit and delete markers from the context menu by right clicking the marker and choosing the option you want.

Using source code frontmatter

Ensure that the frontmatter block is the first thing in your note.

---
marker:
  - coordinates: 100, 300
    icon: lucide-tree-pine
    colour: "#039c4b"
    minZoom: 1
  - coordinates: 5, 5
    mapName: mapName
    colour: "#bdf123"
---

Keep in mind that markers are arrays, many code editors automatically add an - when you start a new line. Ensure you only have the dashes where a new marker entry starts.

Setting What it does
Map name mapName If you want this marker to only show for a certain map, set this to the mapname of that map
Coordinates coordinates Where the marker is placed on the map
Icon icon Which icon to use for the marker. Can be any lucide icon.
Colour colour Which colour the marker will be
Minimal zoom minZoom How far zoomed in the map should be before the marker becomes visible

Technically only 'coordinates' is required for the marker to be valid. However you'll likely end up using most of the other settings.

Coordinates can easily be obtained using the 'copy' (📌) tool in the map. Clicking a spot on the map automatically copies the coordinates to your clipboard.

Adding icons to Obsidian

Any icons added to Obsidian using another plugin should work just fine as long as their icons stick to Obsidian's design limitations. However, these icons likely won't work with Quartz.

  1. Go to the Iconify website and find the iconset you want.
  2. Select any icon and find the set prefix. In the image this is game-icons find iconset prefix
  3. Now go to the Iconify Github and find the json file that corresponds to your chosen set. Open it. find iconset file
  4. Download the raw file download iconset file
  5. Open Obsidian. The open your vault settings. Under community plugins, go to Leaflet bases
  6. Under Additional icon sets, find the option to add iconsets and click the button. It will open a prompt where you can select the file you just downloaded. Press open and the iconset has been added!

Installation

This plugin currently requires Obsidian v1.11.4 or later to work.

Install via Community Plugins

You can find the plugin here.

Install via BRAT

  1. Install the BRAT plugin under Community Plugins.
  2. Open BRAT settings and click "Add beta plugin".
  3. Enter the URL of this repository: https://github.com/Requiae/obsidian-leaflet-bases-plugin.
  4. Under "Select a version", choose the Latest version.
  5. Click "Add plugin".

Alternatives

The OG for Obsidian fantasy maps has to be mentioned. It is no longer under active development and has been in maintenance mode for years.

This plugin is awesome, comprehensive, and feature rich. If you do not wish to use Obsidian bases, your markers to be saved in your notes, nor to host your garden using Quartz then I highly recommend you to take a look at this plugin!

My inspiration and my frustration, for it does not allow images to be used for your maps, and the workarounds are difficult, not accessible, and tend to break GitHub ToS.