Skip to content

NullPointer exception on view reset and simulataneous removal of feature #1654

@spamdaemon

Description

@spamdaemon

I got this error while zooming out in my application:

Uncaught TypeError: Cannot call method 'latLngToLayerPoint' of null leaflet-src.js:4842
L.Polyline.L.Path.extend.projectLatlngs leaflet-src.js:4842
L.Polygon.L.Polyline.extend.projectLatlngs leaflet-src.js:5069
L.Mixin.Events.fireEvent leaflet-src.js:389
L.Map.L.Class.extend._resetView leaflet-src.js:1843
L.Map.include.setView leaflet-src.js:7949
L.Map.ScrollWheelZoom.L.Handler.extend._performZoom leaflet-src.js:6220
(anonymous function)

I believe this is caused by me removing features that have become too small to be visible. I do this removal in the view-reset or zoom-end, which ever hits first.

I guess what's happening is this sequence:

  1. viewreset event is fired
    1.1 get all listeners for this event
    1.2 start firing events
    1.2.1 my map listeners notices that zoom is too low, so remove a feature which is in the list of listeners (1.1) and set it's _map to null
    1.2.2 listener the feature that's been removed is called with its map set to null.

Using leaflet 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions