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

i can't change a clolor of markers or circles? #62

Open
4pmaster opened this issue Jun 7, 2017 · 17 comments
Open

i can't change a clolor of markers or circles? #62

4pmaster opened this issue Jun 7, 2017 · 17 comments

Comments

@4pmaster
Copy link

4pmaster commented Jun 7, 2017

My enviroment is ubuntu 14.04/anaconda/jupyter notebook.
I've try to do someting with colours of circlemarkers and markers but nothing changes, colour still blue.
What i can do to fix it?

Thank you!

@mxndrwgrdnr
Copy link

+1 for this issue. I'm seeing the same thing.

@kylehounslow
Copy link

Same for me. Would be nice to have colours not hard-coded as #0033FF

@martinRenou
Copy link
Member

Unfortunately it is not possible to change color of markers in leaflet. But you can change color of a CircleMarker with my_circle_marker.color = "red" or my_circle_marker.color = "#B4D455", it works fine, at least on master.
Keep in mind that when you change the color with the color attribute it will only change the border color of the circle, if you change the color with the fill_color attribute it will fill the circle with the given color, but you would have to change the fill_opacity if you want to see it clearly (fill_opacity is equal to 0.2 by default)

@deeplook
Copy link
Contributor

Unfortunately it is not possible to change color of markers in leaflet.

Why can't there be something as simple as in https://github.com/python-visualization/folium:

Screenshot 2019-04-15 at 17 29 45

@martinRenou
Copy link
Member

Good point. We should look at what is done in Folium. If you feel like doing it please go ahead @deeplook :) That'd be awesome

@martinRenou
Copy link
Member

Folium uses https://github.com/lvoogdt/Leaflet.awesome-markers

@OliverEvans96
Copy link

Awesome icons only seem to support a fixed set of colors, is that true? I'm getting:

TraitError: The 'marker_color' trait of an AwesomeIcon instance must be any of ['white', 'red', 'darkred', 'lightred', 'orange', 'beige', 'green', 'darkgreen', 'lightgreen', 'blue', 'darkblue', 'lightblue', 'purple', 'darkpurple', 'pink', 'cadetblue', 'white', 'gray', 'lightgray', 'black'], but a value of '#fde725' <class 'str'> was specified.

Have there been any updates on this issue since last year? It would be great to be able to use arbitrary colors to represent a continuous variable at discrete locations with markers + a colorbar.

Thanks,
Oliver

@martinRenou
Copy link
Member

You are right, you can only use a set of colors, simply because those icons are coming from image files.

We could add a new kind of marker that accept any kind of RGB color as input. It would indeed be a nice feature.

@giswqs
Copy link
Contributor

giswqs commented Apr 4, 2020

I was also looking for a way to change marker colors. This would be a nice feature to add.

@martinRenou
Copy link
Member

martinRenou commented Apr 5, 2020

Currently, the only way to change marker colors is by using custom icons, see https://ipyleaflet.readthedocs.io/en/latest/api_reference/icon.html. You can also use the FontAwesome icons, which allows to change the color: https://ipyleaflet.readthedocs.io/en/latest/api_reference/awesome_icon.html

@giswqs
Copy link
Contributor

giswqs commented Apr 5, 2020

@martinRenou Many thanks for the info! Will try it out.

@deeplook
Copy link
Contributor

deeplook commented Oct 15, 2020

I've tried changing the color of an AwesomeIcon, but in vain. Only if I reload the current browser page the new color is shown, weird. And while a CircleMarker can change color it cannot be moved on the map.

Screenshot 2020-10-15 at 10 42 40

@martinRenou
Copy link
Member

@deeplook https://ipyleaflet.readthedocs.io/en/latest/api_reference/awesome_icon.html#interactions

And while a CircleMarker can change color it cannot be moved on the map.

Can you provide a code sample that replicate the issue?

@deeplook
Copy link
Contributor

There is no on_move():

Screenshot 2020-10-15 at 10 56 20

@martinRenou
Copy link
Member

Indeed. In LeafletJS the CircleMarker is not a Marker. I opened an issue for a couple of years ago but I don't think they took it into account.

You can still observe the location property though marker.observe(callback, 'location')

@deeplook
Copy link
Contributor

Yes, but I cannot move the CircleMarker with the mouse... ;)

@martinRenou
Copy link
Member

I guess it's a limitation of LeafletJS, we cannot do anything about it in ipyleaflet

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

No branches or pull requests

8 participants