PyWebIO
PyWebIO copied to clipboard
[Feature Request] Leaflet or Folium integration
Is there any way to use Leaflet.js on PyWebIO?
Kind Regards
Please move to Discussions - Feature Request for posting.
Do you have to use JS packages? They both have corresponding Python libraries, which can put maps on your pywebio apps.
Do you have to use JS packages? They both have corresponding Python libraries, which can put maps on your pywebio apps.
I tried with pywebio.output.put_html(html) for folium, but without success. The Python packages are more limited, so if there is a way to use them in pure js, it would be great!
Please take look at Leafmap: https://github.com/giswqs/leafmap
I was able to use put_html to add maps to my page.
Do you have to use JS packages? They both have corresponding Python libraries, which can put maps on your pywebio apps.
I tried with pywebio.output.put_html(html) for folium, but without success. The Python packages are more limited, so if there is a way to use them in pure js, it would be great!
@Filhomn
Did you get it to work?
It works for me:
from pywebio import *
import folium
def main():
m = folium.Map(location=[45.5236, -122.6750])
output.put_html(m)
start_server(main, port=8080, debug=True)
also @pstatonwx
@wang0618 thanks! was just checking to see if they were successful :)
Yes, I did! Sorry, for not giving the feedback before. I recommend using Ipyleaflet instead of Folium… It is more close to the original Leaflet js library. Thanks!
Yes, it works on jupyter, but it is possible to implement on pywebio as well:
`from ipyleaflet import Map from ipywidgets import embed from pywebio import start_server, config
def bmi(): lat, lon = 18, 95 m = Map(center=(lat,lon), zoom=3) snippet = embed.embed_snippet(views=m) html = embed.html_template.format(title="", snippet=snippet) put_html(html)
if name == 'main': start_server(bmi, port=8080,debug=True, static_dir= './static') `
Awesome!! Haha I deleted my comment right after I posted it because I was like "well that's a dumb thing to ask"
Not really dumb… It still doesn’t have the same interactivity as in jupyter. But, It would be great if pywebio works with ipywidgets!