I have a Google Map involving several different arrays of data, and I'm having trouble coding sections of it efficiently. For example, I have this chunk of code, and would like to turn it into a function that runs the same thing for various different names instead of just Wilma. I can easily make an array holding the names, and pass that as a parameter, but then how would I build array names like "data_NAME[k][3]"? I imagine it must be simple to concatenate a string with part of an array name, but I'm stuck on syntax. Any help is greatly appreciated.
if (currentcroc == 'Wilma') {
for (k = 0; k < data_wilma.length; k++) {
var pointmarker = new google.maps.Marker({
position: latlng_wilma[k],
icon: markerType['point'+data_wilma[k][3]],
shadow: markerType['pointshadow'],
shape: pointshape,
map:map,
zIndex: 4
});
pointarray.push(pointmarker);
(function (k, pointmarker) {
google.maps.event.addListener(pointmarker, 'mouseover', function() {
tooltip.show('Wilma: '+data_wilma[k][2]);
});
google.maps.event.addListener(pointmarker, 'mouseout', function() {
tooltip.hide();
});
})(k, pointmarker);
}
}