felixhayashi / TW5-TiddlyMap

Map drawing and topic visualization for your wiki
http://tiddlymap.org
BSD 2-Clause "Simplified" License
863 stars 132 forks source link

Limit Zoom and Pan Function to Within Background Image #377

Closed HazelMorris closed 4 years ago

HazelMorris commented 4 years ago

Hello, I love tiddlymap and I am currently using this plugin to create an interactive map for worldbuilding. However I have a question/feature request.

I want to have it so you cant zoom or pan out further then the edge of the background image (my map).

In my leaflet version, I used this code:

var map = L.map('map').setView([0, 0], Zoom = 4);

var southWest = L.latLng(-85, -180), northEast = L.latLng(85, 180); var bounds = L.latLngBounds(southWest, northEast);

map.setMaxBounds(bounds); map.on('drag', function() { map.panInsideBounds(bounds, { animate: false }); });

Can anyone help me out? Thank you for creating this amazing plugin! H disclaimer: I have no idea how to code beyond the complete basics.

felixhayashi commented 4 years ago

Hi Hazel, thanks for the feedback and great to hear that you find TiddlyMap useful. I am sorry to say, but unfortunately it is not possible to restrict the zoom of the map :slightly_frowning_face:

HazelMorris commented 4 years ago

Thank you for taking the time to write back, and thank you again for this amazing plugin - you really are a genius! I hope tiddlywiki continues to get the recognision it deserves as a ground breaking piece of software.

felixhayashi commented 4 years ago

Thanks for your warm words @HazelMorris :blush: I know TiddlyMap has its limits and also several shortcomings, but I am glad you find it useful.