Adds the maps center and zoom as a permalink for Leaflet maps.
Initially based on the work of MarcChasse.
- works with Leaflet 1.9.4
- Should work with all modern browsers
- also works with asynchronously loaded elements
- There may be a problem to detect the initial state if you have a slow loading website or an impatient user.
-
Create a leaflet map. Checkout Leaflets Quick Start Guide for a basic map example.
-
Download and include leaflet.permalink.min.js
<script src="../leaflet.permalink.min.js"></script>
- Add the following code to the map initialization:
// create map
var map = new L.map(...);
// call this
map.whenReady ( function() {
L.Permalink.setup(map);
});
see here.
Checkout the DEMO.
If you are using WordPress and the plugin Leaflet Map there is an example too.