function populateInfoWindow(marker, street, city, phone, infowindow) {
    // Check that infowindow is not already opened on this marker.
    if (infowindow.marker != marker) {
        // Clear infowindow content to give streetview time to load.
        infowindow.setContent('');
        infowindow.marker = marker;

        // Clear marker property if the infowindow is closed.
        infowindow.addListener('closeclick', function() {
            infowindow.marker = null;
        });
        var streetViewService = new google.maps.StreetViewService();
        var radius = 60;

        var windowContent = '<h4>' + marker.title + '</h4>' + 
            '<p>' + street + "<br>" + city + '<br>' + phone + "</p>";

        // If the status is OK, which means the pano was found, compute the
        // position of the streetview image, then calculate the heading, get a
        // panorama from that, and set the options
        var getStreetView = function (data, status) {
            if (status == google.maps.StreetViewStatus.OK) {
                var nearStreetViewLocation = data.location.latLng;
                var heading = google.maps.geometry.spherical.computeHeading(
                    nearStreetViewLocation, marker.position);
                infowindow.setContent(windowContent + '<div id="pano"></div>');
                var panoramaOptions = {
                    position: nearStreetViewLocation,
                    pov: {
                        heading: heading,
                        pitch: 20
                    }
                };
                var panorama = new google.maps.StreetViewPanorama(
                    document.getElementById('pano'), panoramaOptions);
            } else {
                infowindow.setContent(windowContent + '<div style="color: purple">Street View Unavailable</div>');
            }
        };
        // GoogleMaps streetview service gets the closest streetview image 
        // within 60 meters of the marked position
        streetViewService.getPanoramaByLocation(marker.position, radius, getStreetView);
        // Open the infowindow on the correct marker.
        infowindow.open(map, marker);
    }
}
// and will show info based on that marker's position.
and will show info based on that marker's position.
and will show info based on that marker ' s position .
function populateInfoWindow(marker, street, city, phone, infowindow) {
    if (infowindow.marker != marker) {
        infowindow.setContent('');
        infowindow.marker = marker;
        infowindow.addListener('closeclick', function() {
            infowindow.marker = null;
        });
        var streetViewService = new google.maps.StreetViewService();
        var radius = 60;
        var windowContent = '<h4>' + marker.title + '</h4>' + 
            '<p>' + street + "<br>" + city + '<br>' + phone + "</p>";
        var getStreetView = function (data, status) {
            if (status == google.maps.StreetViewStatus.OK) {
                var nearStreetViewLocation = data.location.latLng;
                var heading = google.maps.geometry.spherical.computeHeading(
                    nearStreetViewLocation, marker.position);
                infowindow.setContent(windowContent + '<div id="pano"></div>');
                var panoramaOptions = {
                    position: nearStreetViewLocation,
                    pov: {
                        heading: heading,
                        pitch: 20
                    }
                };
                var panorama = new google.maps.StreetViewPanorama(
                    document.getElementById('pano'), panoramaOptions);
            } else {
                infowindow.setContent(windowContent + '<div style="color: purple">Street View Unavailable</div>');
            }
        };
        streetViewService.getPanoramaByLocation(marker.position, radius, getStreetView);
        infowindow.open(map, marker);
    }
}
function populateInfoWindow ( marker , street , city , phone , infowindow ) { if ( infowindow . marker != marker ) { infowindow . setContent ( '' ) ; infowindow . marker = marker ; infowindow . addListener ( 'closeclick' , function ( ) { infowindow . marker = null ; } ) ; var streetViewService = new google . maps . StreetViewService ( ) ; var radius = 60 ; var windowContent = '<h4>' + marker . title + '</h4>' + '<p>' + street + "<br>" + city + '<br>' + phone + "</p>" ; var getStreetView = function ( data , status ) { if ( status == google . maps . StreetViewStatus . OK ) { var nearStreetViewLocation = data . location . latLng ; var heading = google . maps . geometry . spherical . computeHeading ( nearStreetViewLocation , marker . position ) ; infowindow . setContent ( windowContent + '<div id="pano"></div>' ) ; var panoramaOptions = { position : nearStreetViewLocation , pov : { heading : heading , pitch : 20 } } ; var panorama = new google . maps . StreetViewPanorama ( document . getElementById ( 'pano' ) , panoramaOptions ) ; } else { infowindow . setContent ( windowContent + '<div style="color: purple">Street View Unavailable</div>' ) ; } } ; streetViewService . getPanoramaByLocation ( marker . position , radius , getStreetView ) ; infowindow . open ( map , marker ) ; } }
and will show info based on that marker's position.
and will show info based on that marker ' s position .
// Check that infowindow is not already opened on this marker. // Clear infowindow content to give streetview time to load. // Clear marker property if the infowindow is closed. // If the status is OK, which means the pano was found, compute the // position of the streetview image, then calculate the heading, get a // panorama from that, and set the options // GoogleMaps streetview service gets the closest streetview image  // within 60 meters of the marked position // Open the infowindow on the correct marker.