Leaflet: Cannot read property '_leaflet_id' of undefined

Created on 17 Oct 2012  ·  4Comments  ·  Source: Leaflet/Leaflet

Some time when refreshing the page I am getting this error in chrome:

Uncaught TypeError: Cannot read property '_leaflet_id' of undefined leaflet.js:6
(anonymous function) leaflet.js:6
n.Map.n.Class.extend.hasLayer leaflet.js:6
domController.map.manageZoom domController.leaflet.js:647
n.Mixin.Events.fireEvent leaflet.js:6
n.Map.n.Class.extend._resetView leaflet.js:6
n.Map.include.n.DomUtil.TRANSITION._onZoomTransitionEnd leaflet.js:6
n.Map.include.n.DomUtil.TRANSITION._catchTransitionEnd leaflet.js:6
e.(anonymous function).u

this happen when:

if (!map.hasLayer(tilelayer)) {}

Any idea why this is happening and how to solve it?
When this happens the map gets unusable until refresh.

Most helpful comment

This happens when tilelayer variable is undefined at the moment when this line executes. Put a debugger statement there and figure it out, shouldn't be hard.

All 4 comments

This happens when tilelayer variable is undefined at the moment when this line executes. Put a debugger statement there and figure it out, shouldn't be hard.

Thank you.

Hi,

I'm having the same problem with Leaflet 1.0 Beta. I got this error:

Uncaught TypeError: Cannot read property '_leaflet_id' of undefined

on this line:
obj._leaflet_id = obj._leaflet_id || ++L.Util.lastId;

on stamp function

Can you help me with this please?. I created a new ticket (https://github.com/Leaflet/Leaflet/issues/3877)

这个问题一般是由于你用addLayer(tileLayer)时,这个tileLayer值为null引起的,检查一下tileLayer的初始化是否正确

Was this page helpful?
0 / 5 - 0 ratings

Related issues

onethread picture onethread  ·  3Comments

piehei picture piehei  ·  3Comments

jblarsen picture jblarsen  ·  3Comments

pgeyman picture pgeyman  ·  3Comments

viswaug picture viswaug  ·  4Comments