hey i am trying use panel.interact() with function that return folium map…and error occurs where it says u cant use a non type, can u please tell how will i able to plot my folium map using panel
Hi @PaulCT1998
Welcome to the community. Great question it depends on your use case.
One similar thing (I think) is the Google Map you find in https://panel.holoviz.org/user_guide/Param.html
It would be very helpfull if you could upload a small code sample of what you have tried and write a little bit more of what you wan’t to achieve.
Regarding your specific error it sound like you have None
somewhere where it’s no allowed.
yeah sure well i am new at this so
import folium as fm
def map():
in_lat= 20.5936832
in_long=78.962883
In_map = fm.Map(location=[in_lat,in_long], zoom_start=5)
return In_map
green_p1= fm.map.FeatureGroup()
yellow_p1= fm.map.FeatureGroup()
orange_p1= fm.map.FeatureGroup()
red_p1= fm.map.FeatureGroup()
purple_p1= fm.map.FeatureGroup()
marroon_p1= fm.map.FeatureGroup()
def ploting_():
for lat, lng, Aqi in zip(df_aqi['Latitude'], df_aqi['Longitude'],df_aqi['AQI']):
if(Aqi<50):
green_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56, # define how big you want the circle markers to be
fill_color='green',
fill_opacity=0.8
))
if((Aqi>50) & (Aqi<100)):
yellow_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56, # define how big you want the circle markers to be
fill_color='yellow',
fill_opacity=0.7
)
)
if((Aqi>100) & (Aqi<150)):
orange_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56, # define how big you want the circle markers to be
color='yellow',
fill=True,
fill_color='orange',
fill_opacity=0.7
)
)
if((Aqi>150) & (Aqi<200)):
red_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56, # define how big you want the circle markers to be
fill_color='red',
fill_opacity=0.7
)
)
if((Aqi>200) & (Aqi<300)):
purple_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56, # define how big you want the circle markers to be
fill_color='purple',
fill_opacity=0.7
)
)
if((Aqi>300) & (Aqi<500)):
maroon_p1.add_child(
fm.CircleMarker(
[lat, lng],
radius=56,
color='yellow',
fill=True,
fill_color='maroon',
fill_opacity=0.7
)
)
def livmap(f=80):
on_map=map();
ploting_()
on_map.add_child(green_p1)
on_map.add_child(yellow_p1)
on_map.add_child(orange_p1)
on_map.add_child(red_p1)
on_map.add_child(purple_p1)
return on_map
import panel as pn
pn.extension()
pn.interact(livmap)
error:
TypeError Traceback (most recent call last)
~\anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj, include, exclude)
968
969 if method is not None:
--> 970 return method(include=include, exclude=exclude)
971 return None
972 else:
~\anaconda3\lib\site-packages\panel\viewable.py in _repr_mimebundle_(self, include, exclude)
413 comm = state._comm_manager.get_server_comm()
414 doc = _Document()
--> 415 model = self._render_model(doc, comm)
416
417 if config.console_output != 'disable':
~\anaconda3\lib\site-packages\panel\viewable.py in _render_model(self, doc, comm)
363 if comm is None:
364 comm = state._comm_manager.get_server_comm()
--> 365 model = self.get_root(doc, comm)
366
367 if config.embed:
~\anaconda3\lib\site-packages\panel\viewable.py in get_root(self, doc, comm)
534 """
535 doc = doc or _curdoc()
--> 536 root = self._get_model(doc, comm=comm)
537 self._preprocess(root)
538 ref = root.ref['id']
~\anaconda3\lib\site-packages\panel\layout.py in _get_model(self, doc, root, parent, comm)
134 if root is None:
135 root = model
--> 136 objects = self._get_objects(model, [], doc, root, comm)
137 props = dict(self._init_properties(), objects=objects)
138 model.update(**self._process_param_change(props))
~\anaconda3\lib\site-packages\panel\layout.py in _get_objects(self, model, old_objects, doc, root, comm)
124 else:
125 try:
--> 126 child = pane._get_model(doc, root, model, comm)
127 except RerenderError:
128 return self._get_objects(model, current_objects[:i], doc, root, comm)
~\anaconda3\lib\site-packages\panel\layout.py in _get_model(self, doc, root, parent, comm)
134 if root is None:
135 root = model
--> 136 objects = self._get_objects(model, [], doc, root, comm)
137 props = dict(self._init_properties(), objects=objects)
138 model.update(**self._process_param_change(props))
~\anaconda3\lib\site-packages\panel\layout.py in _get_objects(self, model, old_objects, doc, root, comm)
124 else:
125 try:
--> 126 child = pane._get_model(doc, root, model, comm)
127 except RerenderError:
128 return self._get_objects(model, current_objects[:i], doc, root, comm)
~\anaconda3\lib\site-packages\panel\pane\markup.py in _get_model(self, doc, root, parent, comm)
41
42 def _get_model(self, doc, root=None, parent=None, comm=None):
---> 43 model = self._bokeh_model(**self._get_properties())
44 if root is None:
45 root = model
~\anaconda3\lib\site-packages\panel\pane\image.py in _get_properties(self)
93 data = self._img()
94 if not isinstance(data, bytes):
---> 95 data = base64.b64decode(data)
96 width, height = self._imgshape(data)
97 if self.width is not None:
~\anaconda3\lib\base64.py in b64decode(s, altchars, validate)
78 in the input result in a binascii.Error.
79 """
---> 80 s = _bytes_from_decode_data(s)
81 if altchars is not None:
82 altchars = _bytes_from_decode_data(altchars)
~\anaconda3\lib\base64.py in _bytes_from_decode_data(s)
44 except TypeError:
45 raise TypeError("argument should be a bytes-like object or ASCII "
---> 46 "string, not %r" % s.__class__.__name__) from None
47
48
TypeError: argument should be a bytes-like object or ASCII string, not 'NoneType'

i just want to display the map onto the dashboard
Hi @PaulCT1998
I’ve tried to create an example of using Folium in Panel. I’ve added it as a contribution to the Panel Gallery.
You can find the notebook here https://github.com/MarcSkovMadsen/panel/blob/folium-map/examples/gallery/external/Folium.ipynb and the pull request here. https://github.com/holoviz/panel/pull/1189
Hope it helps
See also https://twitter.com/MarcSkovMadsen/status/1242896463635591168 and share if you like. It will help Pythonistas discover Panel.
Hi @PaulCT1998
I believe what you where trying should have worked and therefore you see a bug in Panel. I’ve created a bug report here https://github.com/holoviz/panel/issues/1191
I also think Folium is such a great package so there should be better support for it in Panel via a pane
. I’ve added a feature request here https://github.com/holoviz/panel/issues/1192.
Thanks a Lot Sir … As i thought it cant be done i tried a different approach by converting map to html and displaying it but that too is in vain… programming can be hard but it is fun…