Layers Control and null as first argument

I am using Leaflet library and I want to add just overlay layer on the map and the first argument sholud be null, right?

But when I do this:

var layerControl = L.control.layers(null,overlay).addTo(this.mapa);

I get this error:

Argument of type 'null' is not assignable to parameter of type 'LayersObject | undefined'.

I am working in Angular 7 and it is .ts file.

Can I get some advice, please?

>Solution :

Try using undefined instead of null in the first argument.

Leave a Reply