New Plugin: Obsidian Leaflet - Interactive maps in notes

Thank you so much for this great plugin. It would be very nice if you can add a feature to show the preview window of the marker.

This plugin can provide a solution for my question: Is it possbile to make internal link over images

1 Like

Are you talking about the Obsidian note preview window that pops up when you hover over an internal link?

Definitely possible to do. It’ll be available as a settings toggle.

3 Likes

Hey, it’s the person from r/DMAcademy! I have some questions and a couple of suggestions.
The option for local images is great! I like the idea above of providing page previews on hover.
I still think it would be great if markers were stored inside the code block, with options as text. Something like

markers:
    marker1, [[File]], 50, 60

Where marker1 is the display name, File is where it links to, and the last two numbers are latitude and longitude.

This would also tie in to another option, to have markers only appear at specific zoom levels. For example, towns might only be visible at level 10, with countries visible at 5. It would be great to have a range, specified with something like “1-5”.
The current system is perfectly usable, but not having the data accessible just makes me a little nervous.

Finally, one issue: I didn’t update for a few days, and was trying to go from .1.7 to .3.1. Each time, though Obsidian claimed to have updated the plugin successfully, the version number stayed on .1.7, and the plugin wouldn’t update. This was persistent even using a VPN and restarting Obsidian. I eventually had to delete and reinstall the plugin (fortunately, I didn’t have much data saved). I’ve never encountered this with any other plugins, so…?

Yeah, that’s right. Thank you! Looking forward this feature.

Finally, one issue: I didn’t update for a few days, and was trying to go from .1.7 to .3.1. Each time, though Obsidian claimed to have updated the plugin successfully, the version number stayed on .1.7, and the plugin wouldn’t update. This was persistent even using a VPN and restarting Obsidian. I eventually had to delete and reinstall the plugin (fortunately, I didn’t have much data saved). I’ve never encountered this with any other plugins, so…?

That’s bizarre. I’ve never encountered this either. Not sure what could have caused it, as when Obsidian updates the plugins it just downloads the new files from the Github release, as far I understand it (same as installing it).

If anyone else runs into this issue, could you let me know?

I still think it would be great if markers were stored inside the code block, with options as text.

Since it seems like this is something the people want, I can definitely implement it. It’s possible to wait until the file is closed to update the code block which should get around the screen flickering issue. On maps with a lot of markers, it could cause the code block to get extremely long, though.

There is also be the possibility of storing marker data to a .csv file in the plugin folder.

This would also tie in to another option, to have markers only appear at specific zoom levels. For example, towns might only be visible at level 10, with countries visible at 5. It would be great to have a range, specified with something like “1-5”.

I love this idea and will definitely implement it. This could even be included at the marker “type” level, too, so you could create a Town marker and a Country marker, but override them individually.

2 Likes

The current system is perfectly usable, but not having the data accessible just makes me a little nervous.

Also, all of the marker data is stored in the plugin folder under the data.json file.

2 Likes

Ah, good to know.

Version 1.0.0 released (switching to proper semantic versioning)

  • Added note preview setting. If turned on, hovering a marker with a note target will display the Obsidian-style preview of the note.
  • Added ability to specify map height in % of active window when rendered
3 Likes

Thanks for hearing us!

This is a brilliant idea: Point to a .csv file instead of having all data in the code block. It would allow easily interfacing to external software—most have the ability to export to .csv. Think of a customer database, radio station listener locations, gamer locations, … You could even implement something like “whenever the .csv changes, update the map”!

Instead of keeping the .csv in the plugins’ folder, would it be possible to have it in the folder specified by Settings → Files & Links → Default location for new attachments? It would help with integration, and also prevent people from messing up stuff in the (usually hidden) plugins folder.

2 Likes

Instead of keeping the .csv in the plugins’ folder, would it be possible to have it in the folder specified by Settings → Files & Links → Default location for new attachments ? It would help with integration, and also prevent people from messing up stuff in the (usually hidden) plugins folder.

So it looks like the function to get this path exists (on app.vault.getAvailablePathForAttachments) but isn’t exposed by the API for some reason.

I think I would rather have this be a setting in the plugin’s setting page, instead of using an undocumented function.

Anyway, I’m going to work on fixing a few bugs related to the way I initially store the map references, then I’ll start on this feature.

Just another feature request/idea - some sort of measuring tool would be really useful. Possibly a unique marker type, or perhaps by selecting two markers, or drawing on the map with a hotkey? The scale could be defined in the code block.
Definitely like your current focuses though.

Uuh, measurements … This could open an entirely new can of worms. Years ago, I did such calculations for a company, to determine the probability of customers turning up in a shop, or attending events.

It very much depends on

  • the shape of the world,
  • the coordinate system used, and
  • the kind of map projection used.

Even Earth isn’t a perfect sphere, but an oblate spheroid. Now imagine the difference between, say, Earth, Pratchett’s Discworld, Nivens’ Ringworld, Clarke’s Rama spaceships, or a rather irregular-shaped object like the asteroid 4 Vesta (on which one of my stories plays). :slight_smile:

I agree this can probably be super-simplified, but doing it right is a science of its own. :wink:

Leaflet actually has a method to get the distance (in meters) between two Lat/Long points on the map, so its possible with relatively little code. Leaflet’s source code says it uses an approximation of the spherical law of cosines to do this when done on Earth’s CRS:

  	distance: function (latlng1, latlng2) {
  		var rad = Math.PI / 180,
  		    lat1 = latlng1.lat * rad,
  		    lat2 = latlng2.lat * rad,
  		    sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),
  		    sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),
  		    a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,
  		    c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  		return this.R * c;
  	}

A flat image map uses a “simple” CRS (it just maps lat/long directly to x/y), and thus distance is just the straight line distance between two points. If given a pixel to unit conversion, this could also be done, but it would be on the user to define something that makes sense to them.

Either way this is a pretty easy feature to add. I’ll open an issue for it on github to track it.

1 Like

Interesting, thanks for digging that up! Earth isn’t as flattened as, say, Jupiter or Saturn, so maybe this approximation is actually good enough.

Not that we needed to get parameters for every planet in the universe, but it’s still an interesting topic to talk about. :slight_smile: (I usually refer to it as belonging to my “collection of unneeded knowledge” :rofl:) But I digress …

Looking forward to what other great features you’ll come up with! Have fun!

1.2.0 released

  • Adds simple distance calculator
    • Ctrl/cmd-click between two points (not markers) on the map to display distance between them
    • image maps can be given a scale: and unit: parameter
  • Fixed issue where only one instance of a given map could be open at a time

2.0.0 Released

Hi all! I know its been awhile - other stuff got in the way.

Main updates in this release:

  1. Added the ability to import marker data from a CSV file (@Moonbase59 and @Silvestris, I know you requested something like this).
  2. Added the ability to export marker data to a CSV file.
    • The plugin does not use this file to create markers. If you add markers to it, you must re-import it.
  3. Added an Obsidian-like suggestion box when creating a marker link

I’m planning on adding a feature to let you bulk edit markers on any given map. Should be coming next.

2 Likes

Hi! Loving this plugin! I got a question, how are markers getting saved? I’m working across a few different computers and notice that marker data is not getting synced.

Marker data is in .obsidian/plugins/obsidian-leaflet-plugin/data.json, so maybe you don’t sync the (hidden) .obsidian folder?

1 Like

Is there any way to change the size of the markers on the map?