How can I use leaflet-extra/leaflet-providers
with ngx-leaflet
. A simple example would be nice. I installed leaflet, @types/leaflet, ngx-leaflet, leaflet-providers, @types/leaflet-providers, but I cannot figure out how exactly to link ngx-leaflet with tileLayer.providers('ProviderId'). there should be an .addTo(???map???)
call. Thanks.
Asked
Active
Viewed 1,049 times
0

Sergiu Starciuc
- 532
- 5
- 9
1 Answers
1
If you need access to the map reference, you can follow the instructions here: https://github.com/Asymmetrik/ngx-leaflet#getting-a-reference-to-the-map
There's also a guide with a bunch of examples of how to integrate Leaflet plugins located here: https://github.com/Asymmetrik/ngx-leaflet-tutorial-plugins
It sounds like with this example, you would use the providers plugin to create layers that you'd add to the layers array you are providing to the leafletLayers
input binding or the leafletLayersControl
input binding.
You'd just need to create the layers and add them to the appropriate array or object.
If you can provide some more specific example code I can give you more detail.

reblace
- 4,115
- 16
- 16
-
For some reason the `import { provider } from 'leaflet-providers'` does not import provider function. I followed the examples at https://github.com/Asymmetrik/ngx-leaflet-tutorial-plugins and imported leaflet-providers.js with `import { tileLayer } from 'leaflet'; import 'leaflet-providers'` and it worked. Thanks. – Sergiu Starciuc Mar 02 '18 at 22:11