• Resolved schneidan

    (@schneidan)


    I’m working on a page where I’m using do_shortcode to display a Leaftlet map and add markers for each post from a search result set. I’d like to be able to instruct the maps to reset its bounds to fit whatever markers are on it after the results have all bee added to the page. Having trouble figuring out how to do that with these, though. Any help you can offer?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author bozdoz

    (@bozdoz)

    Right now the best way to do it is to draw an invisible line from all the markers and fit the bounds of that.

    For example, I’ve done this in the past:

    [leaflet-marker address="Victoria, BC"]
    
    [leaflet-marker address="St. John's, Newfoundland"]
    
    [leaflet-line addresses="Victoria, BC; St. John's, Newfoundland" fitbounds=true stroke=false]

    I suppose I could, in the future, add all markers to a group and have some shortcode that adds some extra JavaScript to fit bounds to the entire marker group. It makes sense, and I’ll add that to the next version of the plugin.

    Thread Starter schneidan

    (@schneidan)

    I was thinking the answer might be something like that but hadn’t got it all worked out just yet. Test just now by adding all my marker addresses to an array and imploding it into a line shortcode at the end of the page and presto! Thanks!

    Thread Starter schneidan

    (@schneidan)

    Marking this resolved ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Question about resetting bounds’ is closed to new replies.