Leaflet: TypeError: Result of expression 'map.addLayer' [undefined] is not a function.

Created on 10 Apr 2012  路  1Comment  路  Source: Leaflet/Leaflet

What causes this problem?

TypeError: Result of expression 'map.addLayer' [undefined] is not a function.

I am calling map.addlayer in the function after I initiated the map loading with 2 layers, then when I am trying to add another layer from a function, I got this problem.

How do you solve this issue? I tried some many options how to get var map to be global variable.

I am using jQTouch as web UI (mobile web GUI).

Any ideas how to fix this problem?

Most helpful comment

The problem is, map is not global variable.

Solution:

Window.map = new L.Map('map');

>All comments

The problem is, map is not global variable.

Solution:

Window.map = new L.Map('map');

Was this page helpful?
0 / 5 - 0 ratings