Description
Check for existing bug reports before submitting.
- I searched for existing Bug Reports and found no similar reports.
Expected Behavior
If I add a location to a note's frontmatter, let's say location: [x, y] where x and y are floating point numbers, and try to load the location in the map (using markerfile command), I should get the location marker at that point in the map.
Current behaviour
If I add a location to a note's frontmatter, let's say location: [x, y] where x and y are floating point numbers, and try to load the location in the map (using markerfile command), I instead get a "could not parse location" error popup. The map loads fine but the marker for the note that I was trying to parse doesn't show up at all. This was in my vault with a bazillion different notes and plugins in it. When I used a dummy vault with only one plugin (leaflet) and two notes (dummy-page and map) I could not get the map to load at all if I tried to load the page with the frontmatter coordinates using the markerfile command. It instead gave a different error, "Could not parse lattitude."
Digging deeper, it seems like obsidian will not allow that to be a property of a note. It will do one of two things to it:
- If editing in live preview mode, it will turn it into location: "[x, y]" or location: '[x,y]' (the quotation marks become a part of it)
- If editing in source mode, it will turn into three lines:
location:
- x
- y
The only way I could get it to work was by leaving the note in live preview mode, opening the note in an external program, and manually changing it to [x, y] in there. HOWEVER, when I tried to automate this process (i.e. using python to automatically change all location notes from the above two formats to the [x, y] format) the automation succeeds but as soon as I try to check it onto the map it seems like obsidian itself checks the note and changes it to one of the two aforementioned formats, so it won't show up on the map.
So what this means is, there is no convenient way to parse location on different notes' frontmatter in obsidian. The only way to do it is to manually change it in a different app (e.g. notepad++) and be very careful not to open that note in obsidian source mode. Can't automate it, and can't edit it in obsidian.
Reproduction
- Have Leaflet plugin installed
- Create a new empty note where you put in a map (can just copy-paste a default from the instructions on the github, using openstreetmap as the layer), here is one example (that includes the line added from step 5):
id: leaflet-map
image:
height: 500px
lat: 50
long: 50
minZoom: 1
maxZoom: 10
defaultZoom: 5
unit: meters
scale: 1
marker: default
darkMode: true
markerFile: [[dummy-page]]
- Create a different empty note called "dummy-page" and add one property to it, "location", and attempt to add coordinates to it (e.g. [100,50])
- Go back to the note with the map and add a line "markerFile: [[dummy-page]]"
- You will find that obsidian leaflet cannot load the coordinates for that page as a marker
Which Operating Systems are you using?
- Android
- iPhone/iPad
- Linux
- macOS
- Windows
Obsidian Version Check
1.5.3, installer version 1.4.16
Plugin Version
6.0.1
Confirmation
- I have disabled all other plugins and the issue still persists.
Possible solution
I think it should be a simple fix. Wherever in the plugin it tries to parse frontmatter for different notes, have it search for instances of "[x,y]" in addition to [x,y]. That's it. If there is a simple way to parse multiline, then also add in a parser for line 1: - x line 2: - y so that you get both possibilities. I know this can easily be done in python so hopefully it can easily be done in javascript too.