• Hi, I am using Simplemaps version 2.4.4.1, WordPress 3.3.1.

    I added 2 locations and assigned them each to their own category. If I select 1 it brings results on the map, but if I select both it doesn’t come up with anything.

    I narrowed down the problem to the Inner Join SQL statement, in xml-search.php, line 81-85:

    INNER JOIN
    $wpdb->term_taxonomy AS tax_$i ON
    term_rel_$i.term_taxonomy_id = tax_$i.term_taxonomy_id
    AND tax_$i.taxonomy = '$taxonomy'
    AND tax_$i.term_id $search_value

    which generates this query when I select both categories:

    SELECT
    lat_tbl.meta_value AS lat,
    lng_tbl.meta_value AS lng,
    ( 3959 * ACOS( COS( RADIANS('48.1127929') ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS('11.568187200000011') ) + SIN( RADIANS('48.1127929') ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance,
    posts.ID,
    posts.post_content,
    posts.post_title
    FROM
    wp_posts AS posts
    INNER JOIN
    wp_postmeta lat_tbl ON lat_tbl.post_id = posts.ID AND lat_tbl.meta_key = 'location_lat'
    INNER JOIN
    wp_postmeta lng_tbl ON lng_tbl.post_id = posts.ID AND lng_tbl.meta_key = 'location_lng'
    
    INNER JOIN
    wp_term_relationships AS term_rel_1 ON posts.ID = term_rel_1.object_id
    INNER JOIN
    wp_term_taxonomy AS tax_1 ON
    term_rel_1.term_taxonomy_id = tax_1.term_taxonomy_id
    AND tax_1.taxonomy = 'sm-category'
    AND tax_1.term_id = 16
    
    INNER JOIN
    wp_term_relationships AS term_rel_2 ON posts.ID = term_rel_2.object_id
    INNER JOIN
    wp_term_taxonomy AS tax_2 ON
    term_rel_2.term_taxonomy_id = tax_2.term_taxonomy_id
    AND tax_2.taxonomy = 'sm-category'
    AND tax_2.term_id = 17
    
    WHERE
    posts.post_type = 'sm-location'
    AND posts.post_status = 'publish'
    GROUP BY
    posts.ID
    HAVING distance < 31
    
    ORDER BY
    distance,  posts.post_name ASC
    LIMIT 20

    I did some QA with the database, but I am not sure where exactly the problem lies. If I leave the inner joins out, the results are working just fine (but of course there’s then trouble when I only select one category).

    Any hints?

    Thanks, flymke

    https://www.ads-software.com/extend/plugins/simplemap/

Viewing 5 replies - 1 through 5 (of 5 total)
  • did you figure that out?
    I have same issue.
    any one knows the way this?

    Thread Starter flymke

    (@flymke)

    Actually no. I worked around it:

    <script type="text/javascript">
    $(document).ready(function() {
    // Workaround for Simplemap Bug
    $("#location_search_sm-category_fields input").click(function() {
      $("#location_search_sm-category_fields input").each(function() {
      	$(this).attr('checked', false);
      });
      $(this).attr('checked', true);
    });
    });
    </script>

    So you can only check once a time.. Not pretty but was enough for my needs actually.

    Thanks for your sharing.
    Actually, that’s better solution to me too.
    then where do I have to include that script?

    thank you, flymke, again for your sharing.

    JK

    Thread Starter flymke

    (@flymke)

    No problem, you can put it in the header.php before <body>. You also need to include jquery if you don’t have it (usually you do, but anyway). See if you have the same selectors (#location_search_sm-category_fields input) for the checkboxes.

    Like so:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    // Workaround for Simplemap Bug
    $("#location_search_sm-category_fields input").click(function() {
      $("#location_search_sm-category_fields input").each(function() {
      	$(this).attr('checked', false);
      });
      $(this).attr('checked', true);
    });
    });
    </script>
    <body>
    <!-- ... -->

    Hope that helps!

    Thank you so much for sharing!
    had same issue and works good!! ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: SimpleMap Store Locator] Selecting multiple categories doesn't show results’ is closed to new replies.