'; } else { contentString = '
'+ ''+ ''+ ''+ '

' + m.street + ', ' + m.suburb + '

'+ '
'; } infowindow = new google.maps.InfoWindow({ content: contentString, maxWidth: 300 }); marker['c' + i] = new google.maps.Marker({ position: new google.maps.LatLng(m.lat, m.lon), map: map, // use street or suburb instead of `.name` if desired title: m.street || '' }); marker['c' + i].infowindow = infowindow; google.maps.event.addListener(marker['c' + i], 'click', function () { // Close all previously open InfoWindows for (var key in marker) { if (marker.hasOwnProperty(key) && marker[key].infowindow) { marker[key].infowindow.close(); } } // Then open this one this.infowindow.open(map, this); }); } } // Helper function: recenter the map function panMap(la, lo) { map.panTo(new google.maps.LatLng(la, lo)); } // Helper function: open a marker by matching substring in the .title function openMarker(mName) { // Close all InfoWindows for (var key in marker) { if (marker.hasOwnProperty(key) && marker[key].infowindow) { marker[key].infowindow.close(); } } // Open whichever marker matches the name for (var key2 in marker) { if (marker.hasOwnProperty(key2)) { if (marker[key2].title && marker[key2].title.indexOf(mName) !== -1) { marker[key2].infowindow.open(map, marker[key2]); } } } }