esm7 / obsidian-map-view

Interactive map view for Obsidian.md
MIT License
614 stars 32 forks source link

Shallow `linkedfrom:` #153

Open dmantula opened 1 year ago

dmantula commented 1 year ago

I have an idea for enhancement. Currently linkedfrom: pulls the locations from the current note, as well as ALL locations from referenced notes.

Let's imagine I have a note Trip to Rome.md:

This is my first trip to [[Italy]].

I want to visit:
- [Colosseum](geo:xxx,yyy)
- [[Vaticano]]

What I naturally expect to see on the map in this case is only 2 pins:

BUT. My Italy.md has a lot of different locations. Like a wish-list of different places. Definitely are not relevant my trip. Nevertheless, if I use linkedfrom: then all these places are shown.

My idea is to have another filter linkeddirectlyfrom: or shallowlinkedfrom:. It will take the following locations:

In other words, the only difference would be that the locations from linked notes' inline locations will not be taken.

Judging by the code, it won't be hard to fix. I need to know your opinion, and ideas for the proper naming.

esm7 commented 1 year ago

The scenario you're describing is indeed a weakness of the current linkedfrom: and the expected way of using it. However, I'm concerned that the direction you suggested will be confusing to many users, and create a methodical distinction between inline and front-matter links that the plugin doesn't have today (we're not telling people which to use for what, and I personally mix them all the time by use case).

With the tools currently available in Map View, the problem can be solved by adding to the linkedfrom: query another part, e.g. AND NOT path:Italy. I wonder what are the disadvantage of that, except the fact is it not automatically generated by any means.

dmantula commented 1 year ago

@esm7 You're right. It might be confusing and tightly depends on the taxonomy a user has chosen.

As for me, I've clearly chosen an approach that a frontmatter location is used only for "location"/"site"/"POI" notes that have a single stable location. Like Colosseum that apparently is not going to move. On the other hand, trips, people (and their home/office locations), meeting notes, calendar notes – these notes might be multiple locations, thus the notes have inline geolocations (tagged separately, like "home address", "office address" or "food/pizza", "food/sushi") or references to "site" notes (also, with appropriate tags).

Avoiding confusion among existing users was the reason for introducing another filter name.

The approach with AND NOT path:Italy might work in theory. In practice, it would require adding a new AND statement each time I reference another "noisy" note.

Just curious if anybody else has the same taxonomy and shares my issue. :)

esm7 commented 1 year ago

Out of curiosity, how do you usually construct your filters? Do you normally use "focus note in Map View"? Something else? Do you use presets?

I have another idea that might serve the same purpose, buy in a more generic manner that will not create an implicit distinction between inline and front matter notes that may not suit all users. How about we add a loctype: operator that can filter markers based on their types -- loctype:frontmatter will only show markers defined as a front matter and loctype:inline will only show markers defined as inline. This is really easily doable. What do you think?

GovSat1 commented 1 year ago

I've been mulling this over as well - in my case the best way to handle locations in travel logs.

The way I am doing it now is to create a dedicated note for each place (IE a "Philadelphia, PA" note), and within that note have the single location geo field. Then in my travel log notes I link those place notes ala [[Philadelphia]], and embed a linkedfrom: map in the travel note, so I can see all locations traveled. If it is just a one-off place that likely wont be referenced in the future I'll add an inline geo note (the linkedfrom map includes both)

This way, it doesn't crowd the main map view with a bunch of duplicate markers for each note at the same place. I have the one Philly note, I click that and reference backlinks to view past travel there. Also, easier to link those places with autocomplete to a note over a geo field.

The downside as mentioned above is needing to create separate notes, ala "{City} Hikes" with locations in them, to avoid crowding up my travel note. And in some cases, I would prefer to see all of the notes in the main map view rather than just "Place" notes.