This is inside the google initialize function and works fine. It’s the code below which loops through the markers which is getting marker[i] is undefined
$.each(places, function(index, value) {
x++;
var pos = new google.maps.LatLng(value[1], value[2]);
var icon = value[3];
if(value[3] == 'HI') icon = "NF";
if(value[3] == '') icon = "WH";
marker[x] = new google.maps.Marker({
position: pos,
map:map,
title: value[0],
shadow: shadow,
icon: "../img/markers/" + icon + ".png"
});
marker[x].locType = icon;
});
Here’s the loop outside the initialize function – Getting marker[i] is undefined, doing an alert(marker) gives me [object Object],[object Object],[object Object],[object Object],[object Object] etc….
$(".team").click(function() {
var type = $(this).attr("id");
$.each(marker, function(i, val) {
if(marker[i].locType == type) marker[i].setVisible(false);
})
});
I think the problem is the
this probably indicates that your array start at index
1instead of0so you result probably is:
when running the
$.eachmethod it triesSolution is to move the
x++to the end of the$.each(places, function(index, value) {