w8r / Leaflet.Bookmarks

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

Bookmark data for custom template #7

Closed slongberry closed 9 years ago

slongberry commented 9 years ago

Really like the plugin, it has saved me a ton of time. I have come across one issue though.

We have the ability to customize the way the list of bookmarks appears through the bookmarkTemplate option. However, if I add a custom field to the bookmark, I don't see how to access that data to display it.

I modified the _getBookmarkDataForTemplate function in the code to look more like the _getPopupContent function:

  _getBookmarkDataForTemplate: function(bookmark) {
    if (this.options.getBookmarkDataForTemplate) {
      return this.options.getBookmarkDataForTemplate.call(this, bookmark);
    } else { 
    return {
      coords: this.formatCoords(bookmark.latlng),
      name: this.formatName(bookmark.name),
      zoom: bookmark.zoom,
      id: bookmark.id
      };
    }
  },

This allowed me to write me own custom getBookmarkDataForTemplate function and pass it to the bookmarks control as an option on creation. If there is another way that I should have accessed the data, please let me know.

w8r commented 9 years ago

@slongberry, you did just right, maybe you can adapt that into a pull request?

slongberry commented 9 years ago

I'll send you the PR on Monday morning.

Scott

Sent from my iPhone

On Jul 3, 2015, at 3:26 AM, Alexander Milevski notifications@github.com wrote:

@slongberry, you did just right, maybe you can adapt that into a pull request?

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

slongberry commented 9 years ago

PR submitted. As it is my first PR submitted on Github, please let me know if I need to change anything / do anything differently!

w8r commented 9 years ago

@slongberry, thanks! merged, re-built, published