Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:25:45+00:00 2026-06-05T19:25:45+00:00

Updated Example: http://jsfiddle.net/7Cwbn/62/ You can click on the markers Hold Ctrl to select multiple

  • 0

Updated Example:

http://jsfiddle.net/7Cwbn/62/

You can click on the markers

Hold Ctrl to select multiple options

UPDATE:

I’ve fiddled with the script some more and replaced jQuery.inArray() with array_diff() function as a test statement inside the ifs.

Also I’ve change the if logic a bit. I tried the new code with filtering just the houses and it seems to work, but when I enable the same filtering code for condos too – filtering gets messed up a little.

For example: If I select everything from Features – nothing shows up on the map. But some markers should have showed up since I have at least two of them that have all of the three available features.

$(markers.houses).each(function(index, elem) {
        if ((array_diff(selectedFeatures, elem.features).length === 0) && (array_diff(selectedNearby, elem.nearby).length === 0)) {
            if (!markers.houseMarkers[index].visible) {
                markers.houseMarkers[index].setVisible(true);
            }
        }
    });
$(markers.condos).each(function(index, elem) {
        if ((array_diff(selectedFeatures, elem.features).length === 0) && (array_diff(selectedNearby, elem.nearby).length === 0)) {
            if (!markers.condoMarkers[index].visible) {
                markers.condoMarkers[index].setVisible(true);
            }
        }
    });

FIG 1.1 – Slice of filtering code for houses and condos

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:25:47+00:00Added an answer on June 5, 2026 at 7:25 pm

    You have a typo here (selectedFeaturess) which might have something to do with it:

     if (jQuery.inArray(selectedFeaturess[i], elem.features) !== -1 || jQuery.inArray(selectedFeatures[i], elem.features) > -1) {
    

    Also this isn’t going to help I suspect:

    <option value="Wendy's">Harveys</option>
    

    Code like this:

    if (jQuery.inArray(selectedFeatures[i], elem.features) !== -1 || jQuery.inArray(selectedFeatures[i], elem.features) > -1) {
    

    Can be simplified to just:

    if (jQuery.inArray(selectedFeatures[i], elem.features) !== -1) {
    

    Because if it’s > -1 then it’s !== -1, so the 2nd clause is redundant. e.g. if you had it = 0, then the first part of the IF clause fires and no need for the 2nd part of the IF statement to be executed.

    And finally, here’s a rewrite of your $(document).ready() function. The main problem was how you were looping over the elements in your arrays. Instead of treating them as jquery selectors and doing a .each() on them, you just need to do a simple For loop. But you can use the jquery selector to check their lengths. This works for me (I also renamed Wendy’s to Harveys in the options).

    $(document).ready(function() {
        //$('#filter').on('click', function(e) {
        $('#filter').click(function(e) {
            // prevent refreshing of the page
            e.preventDefault();
    
            // close all infoWindows
            infowindow.close();
    
            // hide all markers
            $(markers.houses).each(function(index, elem) {
                markers.houseMarkers[index].setVisible(false);
            });
            $(markers.condos).each(function(index, elem) {
                markers.condoMarkers[index].setVisible(false);
            });
    
            // get the selected features from select box
            var selectedFeatures = $("#features").val();
            var selectedNearby = $("#nearby").val();
    
            // for each house element...
            $(markers.houses).each(function(index, elem) {
                //first filter by selected features
                if ($(selectedFeatures).length) {
                    for (var i = 0; i < selectedFeatures.length; i++) {       
                        if (jQuery.inArray(selectedFeatures[i], elem.features) !== -1) {    
                            if (!markers.houseMarkers[index].visible) {
                                markers.houseMarkers[index].setVisible(true);
                            }
                        }
                    }
                }
    
                //then filter by nearby selections
                if ($(selectedNearby).length) {
                    for (var i = 0; i < selectedNearby.length; i++) {
                        if (jQuery.inArray(selectedNearby[i], elem.nearby) !== -1) {
                            // if marker is not visible, but meets the filtering criteria - show it
                            // otherwise leave it as it is
                            if (!markers.houseMarkers[index].visible) {
                                markers.houseMarkers[index].setVisible(true);
                            }
                        }
                    }
                }
            });
    
            // for each condo element...
            $(markers.condos).each(function(index, elem) {
    
                // first filter by selected features
                if ($(selectedFeatures).length) {
                     for (var i = 0; i < selectedFeatures.length; i++) {       
                        if (jQuery.inArray(selectedFeatures[i], elem.features) !== -1) {
                            // if marker is not visible, but meets the filtering criteria - show it
                            // otherwise leave it as it is
                            if (!markers.condoMarkers[index].visible) {
                                markers.condoMarkers[index].setVisible(true);
                            }
                        }
                    }
                }
    
                //then filter by nearby selections
                if ($(selectedNearby).length) {
                    for (var i = 0; i < selectedNearby.length; i++) {
                        if (jQuery.inArray(selectedNearby[i], elem.nearby) !== -1) {
                            // if marker is not visible, but meets the filtering criteria - show it
                            // otherwise leave it as it is
                            if (!markers.condoMarkers[index].visible) {
                                markers.condoMarkers[index].setVisible(true);
                            }
                        }
                    }
                }
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update : Added simple test example http://jsfiddle.net/7UhrW/1/ using normalize.css. Chrome/WebKit and Firefox have different
Here's my jsfiddle example: http://jsfiddle.net/7PqqT/ Update: This is my work around solution: http://jsfiddle.net/7PqqT/1/ However
This is an example on http://jsfiddle.net/Eu5by/11/ and on http://jsfiddle.net/Eu5by/12/ ( Update: actually, it doesn't
I have based my code on this example http://jsfiddle.net/rniemeyer/WpnTU/ When you select an item
Can someone provide a good example of multiple UpdatePanels being updated by a singe
i have a problem with the revert speed. Here is a working example http://www.jsfiddle.net/V9Euk/94/
Example code: http://jsfiddle.net/slolife/PnmxM/ I am asking this even though there are a number of
I've made this example in jsfiddle to demonstrate my problem: http://jsfiddle.net/paulmason411/7E6vG/ See how the
I figure I'd demonstrate the problem with an example first, jsfiddle: http://jsfiddle.net/e2UfM/15/ (Tested with
I have updated my website. Previously there were links like these: http://example.com/bla-bla-bla?language=de . After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.