-2

Recently, I found a blog entry where it is shown how to use a leaflet with Angular without using ngx-leaflet: https://codehandbook.org/use-leaflet-in-angular/

What will I have to take care of myself if I do not use ngx-leaflet? For now, basic functionalities such as map display, click event, markers, circles and polygons work, but I worry about more advanced functionalities.

I know that I can have problems with ChangeDetection and Selectors, but does anyone know in which other places I would have problems and what would these problems consist in?

jhpratt
  • 6,841
  • 16
  • 40
  • 50
  • Please don't use tags that are irrelevant with your question (like in this case google-maps, openstreetmap etc) – kboul Jan 28 '19 at 14:59

1 Answers1

1

I wonder if this solution is correct or will not generate problems at a later stage. Will this solution cause errors in more advanced functionalities?

Most likely you wont have issues, considering the fact that the approach in the article works with the lib in the way that its documented, eg.using the L constant.

Although something that isnt mentioned in that article is the use of the @types/leaflet package. That way you can profit from strong typing, and avoid the declare var L stuff.

Maybe ngx-leaflet is not needed anymore?

It never was, so to say. The library simply abstracts the use of leaflet by providing an angular directive. So its basically a more angular-ish way of working (IMO better).

You should choose what suits you best:

You dont want to add an extra dependency or see no gain from its usage (ngx-leflet)?

Fine, then just dont make use of it.

You prefer to use angular components, directives or services in order to hide lower level js libraries?

Fine, then make use of an utility lib like ngx-leaflet.

Jota.Toledo
  • 27,293
  • 11
  • 59
  • 73