-1

I am trying to create a count in a text box which looks at the amount of markers I have visible and store it in my #countBox. I have lots of different filters such as a checkbox, a drop down and a date range to display different results so it will need to work on all of them.

This is where I am at the moment but it is not working.

var count = document.getSelection(markers).style.visibility = "visible";

$.each(unique(marker), function (i, marker) {
    if (marker.setVisible = true) {
        count++;
    }
});
$('#countBox').val(count);
geocodezip
  • 158,664
  • 13
  • 220
  • 245
Tom McDonough
  • 1,176
  • 15
  • 18
  • 2
    Obvious typo : `if(marker.setVisible == true)` (double ==), or just `if (marker.setVisible)`. Although I would expect `setVisible` to be a _method_ that _sets_ the marker as visible, not an attribute that tells whether the marker is visible or not. – Jeremy Thille Jun 03 '15 at 12:56
  • Besides, it looks like this question is a duplicate of http://stackoverflow.com/questions/2906427/how-to-get-all-visible-markers-on-current-zoom-level – Jeremy Thille Jun 03 '15 at 12:58

1 Answers1

0

found it out in the end, I didn't need to use unique as they are all unique any way then I just needed to call each function in every filter.

function countMarkers(markers) {

    var count = 0;
    $.each(markers, function (i, marker) {
        console.log(marker.visible);
        if (marker.visible == true) {
            count++;
        }
    });
    $('#countBox').val(count);
}
Pang
  • 9,564
  • 146
  • 81
  • 122
Tom McDonough
  • 1,176
  • 15
  • 18