infobubble domready - working

new v0.8 code with correct 'domready' placement

by Shabu James

HTML

<script src="https://maps.googleapis.com/maps/api/js?v=3"></script>
<div id="map_canvas"></div>

CSS

html, body, #map_canvas {
    width:100%;
    height:100%;
}

JavaScript

var map;
var infoBubble;

// Initial position of the map
var center = new google.maps.LatLng(-25.363882, 131.044922);

function initialize() {
    // Map options
    var mapOptions = {
        zoom: 4,
        center: center,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    // Attach the map to the document
    map = new google.maps.Map(document.getElementById('map_canvas'),
    mapOptions);
    // The marker
    marker = new google.maps.Marker({
        position: new google.maps.LatLng(-25.363882, 131.044922),
        map: map,
        title: 'marker7'
    });

    infoBubble = new InfoBubble({
        maxWidth: 300,
        minWidth: 300,
        maxHeight: 165,
        minHeight: 165,
        backgroundColor: 'rgba(65,65,65,0.7)',
        disableAnimation: true,
        content: '<div><a class="dialog" href="https://maps.google.com/" target="_blank"></a></div>',
        position: new google.maps.LatLng(-34.397, 150.644)
    });


    google.maps.event.addListener(marker, 'click', function () {
        	console.log('marker just clicked');
        infoBubble.open(map, marker);
        	console.log('line after infoBubble.open');
        google.maps.event.addListener(infoBubble, 'domready', function () {
            	console.log('inside domready function');
			$.get('https://lh4.googleusercontent.com/-_Cox6aEnSkU/UQ_B0LK4khI/AAAAAAAAAzw/4H4dsWGPgeE/s150/go-button.png', function (myImage) {
                	console.log('just got the external image, now let\'s add something completely unrelated...');
				$(".dialog").html('<img id="theImg" src="https://goo.gl/phmzis" />');
                	console.log('apparently that was added, but i don\'t see it on first click');
			})
        });
    });
}

google.maps.event.addDomListener(window, 'load', initialize);

/*
UPDATED infobubble.js attached below - can be found at:
https://github.com/gigmaps/js-info-bubble/blob/gh-pages/src/infobubble.js

*** Note the new placement of `domready` call on line 910 of this...