obsidian-map-view icon indicating copy to clipboard operation
obsidian-map-view copied to clipboard

Adding marker edges *only* to an embedded map

Open johnrobertcobbold opened this issue 2 months ago • 4 comments

Hello @esm7 , thanks for the great plugin. I was playing around with the Links View feature and realized that it seems to be geared at displaying permanent links between markers.

I was wondering if this could be adapted to add edges but only on a specific embedded map. Let's say that I have a couple of markers that I often display in embedded maps on different notes (my journal notes to be specific). They are not always connected or perhaps connected in different ways depending on the route that I took that specific day. Making it possible to define the edges from within the embedded map would allow one to remember the route that was taken on that note (that day in my case). So on those trip maps that you also seem to be found of, one could very easily retrace one's steps, it would be amazing!

So for example on day A note:

Image

but on my day B note:

Image

BONUS: it would be possible to add an arrow shape O------>O , O<------>O by specifying origin, destination

I supposed that something would have to be added to the map code block. I don't know enough about the plugin and Obsidian and I am not sure how one would reference the markers in the block? By their full name ? By adding some identifier to the Obsidian link used (I use "linkedfrom:\"$filename$\"" on my embedded maps so linked markers referenced in that note appear on the map) ? By adding some kind of id property to marker notes for easier referencing ?

Quick example if this can inspire people:

{
   "name":"Default","mapZoom":10,"query":"linkedfrom:\"$filename$\"","chosenMapSource":0, "autoFit":true,
   edges: [
      { from: markerA, to: markerB} // resulting in --->
      { from: markerA, to: markerB, return: true} // resulting in <--->
   ]
}

Thinking beyond, this could perhaps be a good first step before one day implementing something like https://github.com/esm7/obsidian-map-view/issues/267 which included ordered steps with added directions API ?

Looking at some other issues, and while not knowing what you have been preparing for the 6.0 release, I am thinking that this approach could be simpler than having to parse some new geocode by instead using linked notes.

johnrobertcobbold avatar Oct 05 '25 07:10 johnrobertcobbold

First, though that's not what you asked, note that #267 is already implemented in Map View 6.0.0 and you can try the beta version :)

Now to your specific request, you can do that by adding "showLinks":true to the code block. For example:

{"name":"Default","mapZoom":2,"centerLat":27.059125784374068,"centerLng":-43.06640625000001,"query":"","chosenMapSource":4,"autoFit":true,"lock":false,"showLinks":true,"linkColor":"red","markerLabels":"off","embeddedHeight":300}

esm7 avatar Oct 06 '25 04:10 esm7

Just skimmed through the changelog os 6.0.0, looked great, I will be testing it out.

Regarding the above request, it's half-way / a combination of the current links and the new paths:

Instead of inserting a complex path (6.0.0) or always connecting certain markers (current linkfeature), I was suggesting that within one specific embedded map, one could choose to connect certain markers in a specific way. This does mean that they could be connected in another way on a different embedded map. The problem with the current link / showLinks feature is that then those markers are always connected on all maps, that's not at all desirable in certain cases.

The path feature sounds awesome, but I perhaps do not want to insert a full-fledged complex path, I perhaps just want to draw a line between 2 markers on one map, without that link appearing in the interactive view map or on other embedded maps. This is really about creating links only on one single map.

johnrobertcobbold avatar Oct 06 '25 07:10 johnrobertcobbold

Gotcha now. The exact thing you're asking is a nice feature request that needs to be prioritized; maybe it can be generalized nicely by a query-like filter that characterizes which links to show and also how (like display rules). A manual workaround would be to draw the connections manually (in Map View 6.0.0) and filter them in a way that they will show up only where you want them to be (e.g. using some tag), but this sounds very cumbersome :-/

esm7 avatar Oct 07 '25 03:10 esm7

I'm glad you think it's a nice feature request. In some cases, it would be more straightforward than editing a full-fledged path if one does not need a very detailed one between two markers on a specific map. It would allow for more of a quick-view of what was done on a specific note: Oh, on that specific day/trip, I went from "marker" A" to "marker B", without somehow creating a permanent link between A and B on all future embedded maps / interactive view map.

Perhaps the embedded map could query the relevant markers, retrieve their coordinates and generate a GeoJSON on the fly, thus leveraging the new 6.0.0 feature ? It would still require listing the markers to link inside the map block like I sketched in the first post.

johnrobertcobbold avatar Oct 07 '25 06:10 johnrobertcobbold