esm7 / obsidian-map-view

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

using obsidian:// as x,y,z tile server #37

Open zsviczian opened 2 years ago

zsviczian commented 2 years ago

Do you think it is possible to configure leaflet.js to use a local folder in the vault as the maptile source?

https://github.com/esm7/obsidian-map-view/blob/527e04da87c2c0bf4553f1f429d5dda7fd12c0b1/src/mapView.ts#L205-L210

esm7 commented 2 years ago

In theory if the tiles URL is a local file, it should work... https://gis.stackexchange.com/questions/82936/how-i-can-load-tilelayer-in-leaflet-framework-using-local-tiles If this really works, the plugin can add a parser for obsidian:// URLs to convert them to a path using the Vault API.

zsviczian commented 2 years ago

Before raising the issue I did try file:///C:/path/tiles/{z}/{x}/{y}.png but just adding it in settings did not seem to work. I'd be happy with relative path or as you suggest, the plugin converting the obsidian:// link to a local link.

I wouldn't want to state an absolute file:// path, since I am using Obisidian on multiple devices including mobile and desktop...

zsviczian commented 2 years ago

I am afraid loading files with a local file path will not work. This is the error I am getting if I set a local path within the vault: image

I also checked process.cwd(): returned the Obsidian install folder, then changed the working folder to the vault root with process.chdir(), and set a relative path as map source, but got exactly the same error.

image

Would be great to make it work somehow from the vault. Right now I am publishing my map via github pages, and that works fine.