w8r / Leaflet.Bookmarks

Leaflet plugin for user-generated bookmarks
http://w8r.github.io/Leaflet.Bookmarks/
59 stars 17 forks source link

Make bookmarks stay on map after placed #12

Closed rogerhnn closed 8 years ago

rogerhnn commented 8 years ago

I noticed that after I place the bookmark they hide. How I can make them stay on map? Or better, if it uses a layer, can you tell me which layer, so I can toggle it on/off? Thanks, awesome plugin

w8r commented 8 years ago

Can you please provide me with a jsfiddle to see the problem? I'm having difficulties reproducing that

Kind regards, Alexander Milevski

On 25 февр. 2016 г., at 21:21, rogerhnn notifications@github.com wrote:

I noticed that after I place the bookmark they hide. How I can make them stay on map? Or better, if it uses a layer, can you tell me which layer, so I can toggle it on/off? Thanks, awesome plugin

— Reply to this email directly or view it on GitHub.

rogerhnn commented 8 years ago

In your example, the actual bookmarks don't stay on map, they hide if I click on the map. Or if I click to create a new one, the other disappear. Its possible to make them all stay on the map, and not only appear if I click on them in the list?

https://gfycat.com/LividBaggyFinwhale

w8r commented 8 years ago

You can redefine the _onPopupClosed method so that it would store the markers elsewhere

L.Control.Bookmarks.include({
  _onPopupClosed: function(evt) {
    someLayerGroup.addLayer(this._marker);
    this._marker = null;
  }
});
rogerhnn commented 8 years ago

Very nice! I added your plugin to my map, but it doesn't look as pretty as yours. And the bookmarks don't have the edit menu. Can you help me to set it up?

w8r commented 8 years ago

Did you add the leaflet.bookmarks.css file as well?

rogerhnn commented 8 years ago

Yeah, this is how it looks now: http://i.imgur.com/sULre48.png

What I have done so far: Added both leaflet.bookmarks.css and leaflet.bookmarks.js and the control var control = new L.Control.Bookmarks().addTo(map);

I need to manually add a way to add the markers?

I wanna use them on my website: hurtworldmap.com

Do you see the sidebar on the left? Its possible to trigger the add bookmark from an item from there?

Another question, its hard to modify your plugin to include an option to choose an icon for the bookmark when I add it? That would be awesome!

w8r commented 8 years ago

It's hard to tell really. Any styling options could be overridden, but it will take some work. Did you check out the example? There's no additional styling as well

rogerhnn commented 8 years ago

I don't know why, but if I include your css on head or below body, I got an error unexpected token but I copied everything and pasted on my css and it works now. (edited for being a double post)

I use custom coordinates, its possible to change the coordinates shown by your plugin to match mine? I use x and y instead of lat, lng.

Also I found a problem with the code above to make the markers stay on map. If I click to add a new marker, and don't enter a name, and click outside, the marker will stay there. Or if I add the name and click the "+" icon. The marker stay but won't open the popup. I think changing the event onPopupClose to the event that add the marker when clicking the "+" button will solve the problem.