Open rchaklashiya opened 6 months ago
Hi, I had this problem too, but I could "fix" it by just changing the type of frontmatter to list: Then click the location field and just add "lat" Enter "lon" Enter The "times" symbol (x) will be automatically added by Obsidian (when pressing Enter). If I open the markdown file in an external editor this is what I get:
---
location:
- "50.954468"
- "1.862801"
---
This works:
Here is the snippet for the map, even though I dont think it really matters for this problem (and is more or less taken from the README):
id: leaflet-map
height: 1000px
lat: 45.815399
long: 15.966568
minZoom: 1
maxZoom: 15
defaultZoom: 6
unit: m
scale: 1
darkMode: false
markerTag:
- [pnp, my_campaign, poi]
I just ran into this one soon.
What would be really great is if it could parse a value with a preceding name, like some others do:
Houston, Texas [29, -95]
That would let me (and maybe others) keep the same property values.
Check for existing bug reports before submitting.
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:
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
Which Operating Systems are you using?
Obsidian Version Check
1.5.3, installer version 1.4.16
Plugin Version
6.0.1
Confirmation
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.