marker + change background color on click

1,036 views
Skip to first unread message

Filipe Moraes

unread,
Oct 27, 2012, 2:05:35 PM10/27/12
to leafl...@googlegroups.com
How to change the background color of the marke?
See the attached image.
Thank you.


Paulo Vieira

unread,
Oct 27, 2012, 7:01:25 PM10/27/12
to leafl...@googlegroups.com
On Sat, Oct 27, 2012 at 7:05 PM, Filipe Moraes <filipem...@gmail.com> wrote:
How to change the background color of the marke?
See the attached image.

There is no "background color" in the marker. What we see is a .png image that belongs to a L.Icon object, which in turn is associated with the L.Marker object. The default icon has the image you have shown:
http://leafletjs.com/dist/images/marker-icon.png

So to change the "background of the marker" when the user clicks on it, you first have to edit the .png image, then create a new L.Icon and give to it the edited image in the "iconUrl" option. Then is just a matter of subscribing to the click event and use the setIcon method.

For a related subject, see this issue:
https://github.com/CloudMade/Leaflet/issues/1073

WzBn

unread,
Dec 7, 2012, 1:31:33 PM12/7/12
to leafl...@googlegroups.com
Paulo Viera: What about if I'm lokking to chage the fillcolor property of a circleMarker ? Are any way to do that ? Thanks

Nick Lyell

unread,
Jun 10, 2013, 9:57:33 AM6/10/13
to leafl...@googlegroups.com
I also am wondering if this is possible.  I would like to create a circle marker (preferably with SVG) and dynamically fill its color based on the same process used in a cloropleth (and place over U.S. counties).

I suppose I could create a circle .png for each color and just assign them based on the data, but I'm wondering if there is a better way?
Reply all
Reply to author
Forward
0 new messages