Skip to content

hasLayer not checking for null #1282

@paulovieira

Description

@paulovieira

L.Map.hasLayer does this:

var id = L.Util.stamp(layer);

However it might happen that the variable "layer" is null. For instance, there could be a variable like "currentActiveLayer", which might be null. Doing map.hasLayer(currentActiveLayer) results in "Uncaught TypeError: Cannot read property '_leaflet_id' of null".

In a related subject, I think it would be very natural if L.LayerGroup also had a "hasLayer" method.

Thanks.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions