javalent / obsidian-leaflet

Adds interactive maps to Obsidian.md using Leaflet.js
481 stars 29 forks source link

[Bug] local links for markers don't work #361

Closed Sirs0ri closed 1 year ago

Sirs0ri commented 1 year ago

Problem Description

Obsidian has the feature where you can leave out the current note's title to link to headings / ^-anchors inside the current note, this functionality is currently missing from obsidian-leaflet.

Since Obsidian's autocomplete function works inside code blocks, I can type [[# inside of a leaflet codeblock, and I'll get the current file's headings as suggestion, e.g. [[#Main Heading]] for the example below. The marker created from that link will have a popup with the message "#Main Heading" is not created yet. Click to create.

Example Code:

MyNote.md

#Main Heading

This is a full link, this format will work for markers: [[MyNote#Main Heading]]
This link will work only in obsidian's text, not in markers: [[#Main Heading]]

leaflet embed inside MyNote.md:

id: test
lat: 1
long: 1
marker: 
  - default, 0, 0, [[MyNote#Main Heading]], This will work
  - default, 0, 1, [[#Main Heading]], This will not

Additional Info

Obsidian Version: 1.1.16 Leaflet Version: 5.2.6

Correctly created marker correctly created marker

Marker with broken link marker with broken link

sigrunixia commented 1 year ago

@Sirs0ri I cannot recreate this. Can you make sure you are on the latest leaflet version (and check that your obsidian installer version is 1.1.9) and try again? If its still not working, are you able to get an error code from the developers console?

Sirs0ri commented 1 year ago

@sigrunixia I just tried, and yes, the problem still exists (obsidian v1.1.16, installer 1.1.9, obsidian-leaflet 5.5.3)

I just tried in a completely new vault, and: 1) added the leaflet plugin, 2) turned on the "Display Note Preview" setting for Obsidian Leaflet, and 3) created the note "MyNote.md" mentioned above. 4) Clicking the popup links to the correct point in the note, but the note Preview points to the wrong place.

I'll attach the zipped vault below, hoping this helps: obsidian-test.zip

(The vault also includes an example for the problem reported in #366)