Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get filled color for polygon_marker #212

Closed
PBrockmann opened this issue Oct 9, 2015 · 13 comments
Closed

get filled color for polygon_marker #212

PBrockmann opened this issue Oct 9, 2015 · 13 comments
Assignees
Labels
bug An issue describing unexpected or malicious behaviour

Comments

@PBrockmann
Copy link

I cannot get a flat filled color when I use polygon_marker. Instead I get a gradient that comes from Leaflet-DVF I suppose.
But many times, I would prefer to display a flat color.

Another point, I have noticed on the use of the property fill_color from polygon_marker is that the filled color is not displayed when you embed your map in a notebook.

Here is an example tested with 0.1.5

import folium
print folium.__version__

from IPython.display import HTML, display

def inline_map(m):
    if isinstance(m, folium.folium.Map):
        m._build_map()
        srcdoc = m.HTML.replace('"', '"')
        embed = HTML('<iframe srcdoc="{}" '
                 'style="width: {}px; height: {}px; '
                 'border: none"></iframe>'.format(srcdoc, m.width, m.height))
    else:
        raise ValueError('{!r} is not a folium Map instance.')
    return embed
map_5 = folium.Map(width=600, height=400, location=[45.5236, -122.6750], zoom_start=13)

map_5.polygon_marker(location=[45.5318, -122.6745], popup='Broadway Bridge',
                     line_color='red',
                     fill_color='blue', num_sides=8, radius=10, fill_opacity=1)

inline_map(map_5)

folium_02

Inspecting the SVG I find a
fill="url(#gradeac640f5-53f0-6c37-ea2b-10d33cbc9aa0)"
whereas in a saved html with map_5.create_map(path="myfile.html"), I get a
fill='blue' as expected (event if it is a gradient that is finally displayed).

folium_03

@PBrockmann
Copy link
Author

OK I get a solution after reading and testing #135
on "How to use folium with iPython / Jupyter notebook".

from IPython.display import HTML, display

def inline_map(m):
    if isinstance(m, folium.folium.Map):
        m._build_map()
        srcdoc = "data:text/html;base64," + m.HTML.encode('base64')
        embed = HTML('<iframe src="{}" '
                 'style="width: {}px; height: {}px; '
                 'border: none"></iframe>'.format(srcdoc, m.width, m.height))
    else:
        raise ValueError('{!r} is not a folium Map instance.')
    return embed

Using that inline_map function that encodes the src of the iframe in base64 allows correct filling colors for polygon markers.

@PBrockmann
Copy link
Author

I let this issue open because the problem remains with 0.1.6 branch.

Leaving the mapobject as the last line in the notebook to get a rich HTML displayed should display filled colors but it's not the case.

@ocefpaf
Copy link
Member

ocefpaf commented Oct 10, 2015

Ooops! I took me so long to answer that you found the solution 😳

I let this issue open because the problem remains with 0.1.6 branch.

Thanks! I will address that before the v0.1.6. (Now I am almost glad with the huge delay that release 😉)

@ocefpaf ocefpaf self-assigned this Oct 10, 2015
@ocefpaf ocefpaf added this to the v0.1.6 milestone Oct 10, 2015
@ocefpaf ocefpaf added the bug An issue describing unexpected or malicious behaviour label Oct 10, 2015
@ocefpaf
Copy link
Member

ocefpaf commented Oct 31, 2015

@PBrockmann this is fixed in master. I will push for a new release ASAP.

@ocefpaf ocefpaf closed this as completed Oct 31, 2015
@PBrockmann
Copy link
Author

Cool. Thnks.
I have just mentionned folium in a promissing project on WMS. See sci-wms/sci-wms#96
As written I would like to clarify why a "styles" option is needed. It should be "parameters" option. It comes from http://leafletjs.com/reference.html#tilelayer-wms
OpenLayers has a better interface where the "params" option is well defined and easy to use.

@ocefpaf
Copy link
Member

ocefpaf commented Oct 31, 2015

I saw that. I agree that sci-wms is a 👍 (right @kwilcox 😸)

We need to sort #124 out too. I will open another issue for that. Thanks!

@ocefpaf ocefpaf reopened this Nov 2, 2015
@ocefpaf
Copy link
Member

ocefpaf commented Nov 2, 2015

I am re-opening this. Let's port the bug fix to v.0.1.6.

@ocefpaf
Copy link
Member

ocefpaf commented Nov 3, 2015

Done in #234

@ocefpaf ocefpaf closed this as completed Nov 3, 2015
@ocefpaf ocefpaf mentioned this issue Nov 4, 2015
@PBrockmann
Copy link
Author

I have just tested the 0.1.6 release but the bug is still there.
Am I missing something ?

folium_marker

@ocefpaf
Copy link
Member

ocefpaf commented Nov 17, 2015

Yep: #237

To inline everything breaks more stuff than fixes it. The proper fix is in folium v0.2.0 which compartmentalizes the elements. Sorry, but if you can figure out a better way to fix this we can always release a v0.1.7.

Although I strongly recommend you to take a look at the unreleased v0.2.0. There lots of nice feature and improvements to come.

@PBrockmann
Copy link
Author

Ok I will switch to the v0.2.0 when released
Thks

@prodriguezciae
Copy link

Hello all,

This is not working properly in folium 0.11. We still get gradient colors in RegularPolygonMarker. CircleMarker works fine.

Thank you,
Patricio

@davidrosspainter
Copy link

@prodriguezciae I agree, any fix for this - it's quite annoying. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing unexpected or malicious behaviour
Projects
None yet
Development

No branches or pull requests

4 participants