Created
June 25, 2012 18:23
-
-
Save Andrewglass1/2990337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PriceRangeFilter = { | |
min: 0, | |
max: 0, | |
}; | |
var AllPropertyFilters = []; | |
$( "#revenue-range" ).slider({ | |
range: true, | |
min: Market.min_revenue, | |
max: Market.max_revenue, | |
values: [ 0, Market.max_revenue ], | |
slide: function(event, ui) { | |
PriceRangeFilter.min = ui.values[0]; | |
PriceRangeFilter.max = ui.values[1]; | |
applyAllFilters(); | |
$( "#filtered-rev" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); | |
} | |
}); | |
$("input.showhide:checkbox").click(function() { | |
var name = $(this).data('property-name'); | |
var value = $(this).data('property-value'); | |
var shouldShow = $(this).attr('checked') || 'unchecked'; | |
AllPropertyFilters = _.filter(AllPropertyFilters, function(propertyFilter){ return propertyFilter.value != value; }); | |
var filter = {name: name, value: value, shouldShow: shouldShow} | |
AllPropertyFilters.push(filter); | |
applyAllFilters(); | |
}); | |
var applyAllFilters = function(markers, filterList) { | |
for (i in Gmaps.map.markers) { | |
var marker = Gmaps.map.markers[i]; | |
Gmaps.map.showMarker(marker); | |
if(marker.revenue < PriceRangeFilter.min || marker.revenue > PriceRangeFilter.max){ | |
Gmaps.map.hideMarker(marker); | |
} | |
for(i in AllPropertyFilters){ | |
if(marker[AllPropertyFilters[i].name] == AllPropertyFilters[i].value && AllPropertyFilters[i].shouldShow == "unchecked"){ | |
Gmaps.map.hideMarker(marker); | |
} | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment