• reactfitness

    (@reactfitness)


    Hi there.

    I’m going to have multiple markers on my map for events taking place all over the US. Is it possible to have a search box on the map that will search the map when someone puts in their city to find the nearest event?

    Thanks!

    lisa

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author bozdoz

    (@bozdoz)

    could, yeah. it might be a little complex:

    You can access all markers on a page with

    WPLeafletMapPlugin.markers

    You can get the popup content like this:

    WPLeafletMapPlugin.markers.map(marker=>(marker._popup||{})._content)

    And filter that content for place names. Then center the map to the marker:

    
    var marker = WPLeafletMapPlugin.markers.filter(marker=>(marker._popup||{})._content === 'OSLO!')[0];
    marker._map.setView(marker._latlng);
    

    Try it out in the Shortcode Helper page, in your JavaScript developer console (first move the OSLO map somewhere other than OSLO).

Viewing 1 replies (of 1 total)
  • The topic ‘Searchable by Address’ is closed to new replies.