My actual problem is much more specific, but I think a more general answer will help me to cope with future needs.
I actually need to enable leaflet-extras
plugin for leaflet
underlying pyqtlet
.
Documentation says:
Download leaflet-providers.js and include it in your page after including Leaflet, e.g.:
<head>
...
<script src="http://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
<script src="js/leaflet-providers.js"></script>
</head>
and then:
// add Stamen Watercolor to map.
L.tileLayer.provider('Stamen.Watercolor').addTo(map);
Of course all this is in the assumption you are writing a JavaScript app while I am in pyqtlet
environment.
I tried to cope in a very ugly way:
- downloaded
leaflet-providers.js
to myvenv/lib/python3.8/site-packages/pyqtlet/web/modules
- added the line
<script src="modules/leaflet-providers.js"></script>
to myvenv/lib/python3.8/site-packages/pyqtlet/web/map.html
- used
self.map.runJavaScript("L.tileLayer.provider('Stamen.Watercolor'). addTo(map)")
to activate the desiredtileLayer
This actually works, but I'm sure there's a cleaner way to achieve the same.
Any hint welcome.