!function(){

  var map;

  var centerChanged = function(){
    clearTimeout(centerChanged.timeout);
    centerChanged.timeout = setTimeout(refreshMarkers, 300);
  }

  var refreshMarkers = function(){
    var bounds = map.getBounds();
    var northEast = bounds.getNorthEast();
    var southWest = bounds.getSouthWest();

    var data = {
      sw_latitude:  southWest.lat(),
      sw_longitude: southWest.lng(),
      ne_latitude:  northEast.lat(),
      ne_longitude: northEast.lng(),
    };
    console.log(data)
    var request = $.getJSON('/yelp_search', data);
    request.done(function(response){
      drawBusinesses(response.businesses);
    });
  }

  var drawBusinesses = function(businesses){
    businesses.forEach(function(businesse){
      var coordinate = businesse.location.coordinate;
      var marker = new google.maps.Marker({
         position: {
           lat: coordinate.latitude,
           lng: coordinate.longitude,
         },
         map: map,
         title: businesse.name,
      });

      google.maps.event.addListener(marker, 'click', function() {
        console.log('CLICKED ON', businesse);
      });

    });
  }

  $(function(){

    navigator.geolocation.getCurrentPosition(function(position){

      map = new google.maps.Map($('#map-canvas')[0], {
        center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
        zoom: 8,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      });

      setTimeout(refreshMarkers, 1000);

      google.maps.event.addListener(map, 'center_changed', function() {
        centerChanged();
      });

    });

  });

}();
@@ -739,17 +739,16 @@
 business
-e
 )%7B%0A     
@@ -773,17 +773,16 @@
 business
-e
 .locatio
@@ -990,17 +990,16 @@
 business
-e
 .name,%0A 
@@ -1004,24 +1004,122 @@
 %0A      %7D);%0A%0A
+      var infowindow = new google.maps.InfoWindow(%7B%0A        content: marker%5B'title'%5D%0A        %7D);%0A%0A
       google
@@ -1218,12 +1218,48 @@
 ness
-e
 );%0A
+        infowindow.open(map, marker)%0A
     
@@ -1726,33 +1726,32 @@
 ed();%0A      %7D);%0A
-%0A
     %7D);%0A%0A  %7D);%0A%0A

correct 'businesse' typo and added the ability to see marker information when clicked