Get total marker count from Google API placesSearch

Posted by okTalk on Stack Overflow See other posts from Stack Overflow or by okTalk
Published on 2014-06-05T21:07:10Z Indexed on 2014/06/05 21:24 UTC
Read the original article Hit count: 120

In the example fiddle, how can I get the total number of markers displayed on the map? I'm pushing each of the markers into an array like this:

markers.push(marker)

And attempting to get the total number of markers like this:

$('.marker-count span').html(markers.length);

Unfortunately, "markers.length" is returning 0 when it should be returning at least 3. I have example code here: http://jsfiddle.net/287C7/

How can I display the total number of markers? Is it not possible to add each marker to my array?

I need to know the amount of markers shown so that I can alert the user if there are none.

Thanks,

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google-maps