Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

L.hash is not a constructor, init map ? #24

Closed
KolamInstitute opened this Issue · 3 comments

2 participants

Uriel Deveaud Scooter Wadsworth
Uriel Deveaud

I've got some difficulties to activate hash for leaflet.

my code define the map as usual:

            var map = L.map('map', {
        center: new L.LatLng(12.00641296, 79.81030941),zoom: 15,
        layers: [blackwhite, avzonesLayer, circlesLayer ]
    }); //.addHash() ?

    var hash = new L.hash(map);

i've got this error:

L.hash is not a constructor

I'm a bit lost, i use leaflet master 0.5.1...please help here :)

Scooter Wadsworth

As per the standard in Leaflet, the constructor is given with an upper case first letter while the convenience method for creating an instance without use of the new keyword is given with a lower case first letter.

// using constructor directly

var hash = new L.Hash(map);

// note the use of the new keyword here
// also note the upper case 'H' on Hash
// using convenience method

var hash = L.hash(map);

// note the lack of the new keyword here
// also note the lower case 'h' on hash

You may use either form, but the new keyword will only work with the constructor directly (with the upper case H). The new keyword will not work with the convenience method (with the lower case h).

Uriel Deveaud

i tried the second solution:
var hash = L.hash(map);

and it says:
L.hash is not a function !

i don't know how to resolve this, help !

Uriel Deveaud

i fix my issue, thanks for your explaination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.