Support » Plugin: WP Store Locator » Deeplinking to a listing location?

  • Resolved Nicholas

    (@nickpc)


    One final question that you could assist me with, I’d like to have a list of stores underneath the map and when a link to the name of an individual store is clicked on have that info window pop open. I added anchors to the description of each location but it’s not the most elegant and a user would still need to hover over the listing section to have the pin popup.

    Any thoughts or ideas on achieving this? Thank you!

    Nicholas

    https://wordpress.org/plugins/wp-store-locator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Nicholas

    (@nickpc)

    I’m sorry if I’m not explaining myself correctly, I’d like to have a separate list of all locations underneath the default shortcode that when a name is clicked the browser will scroll up to the map and open the info window of the name that was clicked.

    I thought I could achieve this some how with the “More Info” HTML but it only shows More info – So I can’t manually target an individual listing template item as easily as I thought. Thank you for your help!

    Plugin Author Tijmen Smit

    (@tijmensmit)

    This will require some custom code, I don’t really have time to write out the exact code, but I can point you in the right direction.

    First grab all the locations with this.

    $args = array(
        'post_type'      => 'wpsl_stores',
        'post_status'    => 'any',
        'posts_per_page' => -1
    );
    
    $locations = get_posts( $args );

    Loop over them, and grab the location meta with get_post_custom.

    If you look at the html for the search results you will see this.

    <li data-store-id="4571"> The number is the location ID, which is used in the markerArray in the wpsl-gmap.js.

    In this code the storeId holds the data-store-id val, you can use similar code to look up which info window to open once the name is your custom list is clicked.

    For this to work you do have to add the store id somewhere in your custom store list, and once the store title is clicked, grab it, and use it lookup the correct marker.

    for ( i = 0, len = markersArray.length; i < len; i++ ) {
       if ( markersArray[i].storeId == storeId ) {
          google.maps.event.trigger( markersArray[i], "click" );
       }
    }

    You can see the code surrounding the above js code here.

    The wpsl-gmap.min.js is used on the front-end, so you do have to minify the code to make it work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Deeplinking to a listing location?’ is closed to new replies.