Skip to content

Conversation

@BibMartin
Copy link
Contributor

Using a refactoring with ImageOverlay, you can provide an image url, file, or array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed this re-factoring! Thanks!!

@andrewgiessel this is your baby. Can take a quick look at it before we merge this?

@ocefpaf
Copy link
Member

ocefpaf commented Nov 2, 2015

Beautiful!

I just re-wrote my horrible hack using this PR.

http://nbviewer.ipython.org/github/ocefpaf/secoora_assets_map/blob/gh-pages/test_geojson.ipynb

@andrewgiessel
Copy link
Contributor

Yes, I'm on it! I have that and the retina PR at least

On Mon, Nov 2, 2015 at 8:39 AM Filipe [email protected] wrote:

Beautiful!

I just re-wrote my horrible hack using this PR.

http://nbviewer.ipython.org/github/ocefpaf/secoora_assets_map/blob/gh-pages/test_geojson.ipynb


Reply to this email directly or view it on GitHub
#230 (comment)
.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds is not defined here- needs to be passed into from the init method of ImageOverlay

@andrewgiessel
Copy link
Contributor

This is amazing work! Other than the bounds issue I did a line comment on above, it seems like a very nice refactoring.

Do the image_overlay tests still pass? Do we more stuff there?

@BibMartin
Copy link
Contributor Author

bounds is not defined here- needs to be passed into from the init method of ImageOverlay

Silly me ; corrected.

Do the image_overlay tests still pass? Do we more stuff there?

The test still passes ; I did not use mercator_tranform into it.
I'll add another test asap.

@ocefpaf
Copy link
Member

ocefpaf commented Nov 8, 2015

@andrewgiessel Are you OK with @BibMartin's two extra commits?

@andrewgiessel
Copy link
Contributor

Looks great to me, let's merge

ocefpaf added a commit that referenced this pull request Nov 12, 2015
Create CustomIcon as suggested in #228
@ocefpaf ocefpaf merged commit a6664e7 into python-visualization:master Nov 12, 2015
@ocefpaf
Copy link
Member

ocefpaf commented Nov 12, 2015

Looks great to me, let's merge

Done!

@BibMartin BibMartin deleted the issue228 branch December 7, 2015 11:02
@ocefpaf ocefpaf added the enhancement Feature request or idea about how to make folium better label Feb 12, 2016
@ocefpaf ocefpaf added this to the v0.2.0 milestone Feb 12, 2016
@Dhanesh-raj
Copy link

Dhanesh-raj commented May 13, 2021

import os
from io import BytesIO

style_function = lambda feature: dict(fillColor='#DEFFDE',
color='#AECCAE',
weight=1,
opacity=1)
data_cm = kar_latlong
geojson = folium.GeoJson(data=country_shapes,
smooth_factor=2,
style_function=lambda x: {'color':'black','fillColor':'green','weight':1},
tooltip=folium.GeoJsonTooltip(fields=['name'],
labels=False,
sticky=True),
highlight_function=lambda x: {'weight':3,'fillColor':'grey'},
).add_to(world_map)

for i in range(0,len(data_cm)):
icon_image = BytesIO(base64.b64decode(base64.b64encode(open(os.path.join(os.getcwd(),"./icons/",data_cm.iloc[i]['CountryName']+".png"), 'rb').read())))
marker_icon = copy.copy(icon_image)
icon = CustomIcon(
marker_icon,
icon_size=(30, 30),
icon_anchor=(15, 15),
popup_anchor=(-3, -76)
)
folium.Marker(
location=[data_cm.iloc[i]['Latitude'], data_cm.iloc[i]['Longitude']],
icon = icon,
radius=float(15000.0),
popup=folium.Popup(str(data_cm.iloc[i]['CountryName']))).add_to(world_map)

folium.LayerControl(collapsed=True).add_to(world_map)
world_map.save('icon.html')
world_map

**---------------------------------------------------------------------------
NameError Traceback (most recent call last)
in
20 icon_image = BytesIO(base64.b64decode(base64.b64encode(open(os.path.join(os.getcwd(),"./icons/",data_cm.iloc[i]['CountryName']+".png"), 'rb').read())))
21 marker_icon = copy.copy(icon_image)
---> 22 icon = CustomIcon(
23 marker_icon,
24 icon_size=(30, 30),

NameError: name 'CustomIcon' is not defined**

How can I solve this? i saved my custom icons in local folder instead of using icon_url

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request or idea about how to make folium better

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants