Add URL hashes to web pages with Leaflet maps
JavaScript
Pull request Compare This branch is 59 commits ahead, 18 commits behind mlevans:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
screenshots
test
.gitignore
LICENSE.md
README.md
leaflet-hash.js
package.json

README.md

Leaflet-hash

Leaflet-hash lets you to add dynamic URL hashes to web pages with Leaflet maps. You can easily link users to specific map views.

Leaflet-hash

Demo

You can view a demo of leaflet-hash at calvinmetcalf.github.com/leaflet-hash.

Getting started

  1. Prepare a basic leaflet map. You can find instructions on Leaflet's quick-start guide.

  2. Include leaflet-hash.js.

  3. Once you have initialized the map (an instance of L.Map), add the following code:

        // Assuming your map instance is in a variable called map
        map.addHash();
  4. optionally you can pass a an object with a few options
    • lc: pass an instance of L.Control.Layer, the baselayers will be put in the hash
    • path: template for the url hash, defaults to '{z}/{lat}/{lng}' or '{base}/{z}/{lat}/{lng}' if lc is specified, parts need to be seperated by "/"
    • formatBase: an array of length 2 that will be used as the arguments of the overlay names before they go into the url hash, the default turns whitespace to underscores and all lowercase just pass "[//]" if you want it unchanged

Author

@mlevans

Contributors

@rsudekum

@yohanboniface

@calvinmetcalf

@tmcw

License

MIT License. See LICENSE for details.