Leaflet / Leaflet.toolbar

Flexible, extensible toolbars for Leaflet maps.
MIT License
197 stars 70 forks source link

markers edition #25

Closed mmeinert closed 9 years ago

mmeinert commented 9 years ago

Hi,

Seems I can't edit color of a marker when selected. Same on your popup example.

Do you think possible to make a list of 4 other markers in place changing his color ?

justinmanley commented 9 years ago

Michael, thanks for pointing this out.

I left it this way mostly because I was lazy. Leaflet markers, unlike other layers are based on images, and so there's no (easy) way to change the color of a marker using JavaScript alone, as with polylines, polygons, etc.

There are two good solutions to this:

  1. Use a library (such as font-awesome-markers) that provides markers of different colors.
  2. Only show the "Edit Color" option when the layer that the toolbar is being attached to is not an instance of L.Marker.

I'm particularly interested in solution #2, because I think that it touches on an important use case. Any situation where the actions you want to expose to the user are dependent on the target object might fit this model. For example - users might have read privileges to all objects on a map, but they might only have edit privileges to those they created.

I experimented with a 'filter' option to Leaflet.Toolbar before, but didn't follow through. I think this is the perfect use-case for such an option! On Mar 18, 2015 9:30 AM, "Michaël Meinertzhagen" notifications@github.com wrote:

Hi,

Seems I can't edit color of a marker when selected. Same on your popup http://leaflet.github.io/Leaflet.toolbar/examples/popup.html example.

Do you think possible to make a list of 4 other markers in place changing his color ?

— Reply to this email directly or view it on GitHub https://github.com/Leaflet/Leaflet.toolbar/issues/25.

mmeinert commented 9 years ago

Hi @manleyjster, thank you for your answer. I'm currently learning JS, thanks to CodeAcademy and other ressources. This will help me to participate in projects like yours.