Skip to content

Add URL hashes to web pages with Leaflet maps. Support BaseLayer in hash and Leaflet Rc3

License

Notifications You must be signed in to change notification settings

ClaudioCas/leaflet-hash

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Working with latest leaflet.js (Rc3) Based on working of @calvinmetcalf

Leaflet-hash

Demo

Clone or Download git and execute example.html

Getting started

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

  2. Include [leaflet-hash.js] or [leaflet-hash.min.js] (https://raw.github.com/claudiocas/leaflet-hash/master/dist/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

@claudiocas

License

MIT License. See LICENSE for details.

About

Add URL hashes to web pages with Leaflet maps. Support BaseLayer in hash and Leaflet Rc3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.8%
  • HTML 1.2%