Skip to content Skip to sidebar Skip to footer

Multiple Intersecting Filters Google Maps Api

I have searched up and down for weeks trying to figure out how to filter for multiple criteria using JavaScript and the Google Maps API, and have found this which is essentially t

Solution 1:

@treighton try setting up markers with few details for testing purposes, for example :

marker1=newgoogle.maps.Marker({title :title,position :pos,category :category,city :city,map :map});

Here we have a title, position, category and city tagged in each marker. Fewer codes/lines to type means higher percentage to pinpoint the cause of the problem. Now that the tagging of some filters are done we now create a function for filtering (hide and show) of the marker.

for (i = 0; i < markers1.length; i++) {
            marker = gmarkers1[i];
            // If is same category or category not pickedif ((marker.city == city || city.length===0) && (marker.category == category || category.length===0)) {
                marker.setVisible(true);
            }
            // Categories don't match else {
                marker.setVisible(false);
            }
        }

Post a Comment for "Multiple Intersecting Filters Google Maps Api"