<script>
var map_{{map_id}};
var my_maps = (my_maps) ? my_maps : [];
var my_markers = (my_markers) ? my_markers : [];

$(function () {
	function google_maps_init_{{map_id}} () {
		if (typeof google === 'undefined' || typeof google.maps === 'undefined' || typeof google.maps.Geocoder === 'undefined') {
			setTimeout (google_maps_init_{{map_id}}, 50);
			return;
		}

		var georeq = {address: "{{address}}, {{city}}, {{state}}, {{country}} {{zip}}"},
			geocoder = new google.maps.Geocoder (),
			map_opts = {
				zoom: 14,
				center: new google.maps.LatLng (-34.397, 150.644),
				mapTypeId: google.maps.MapTypeId.ROADMAP
			};
		map_{{map_id}} = new google.maps.Map (document.getElementById ("map-{{map_id}}"), map_opts);
		my_maps.push (map_{{map_id}});

		geocoder.geocode (georeq, function (results, status) {
			console.log (status);
			console.log (results);
			if (status == google.maps.GeocoderStatus.OK) {
				map_{{map_id}}.setCenter (results[0].geometry.location);
				var marker = new google.maps.Marker ({
					map: map_{{map_id}},
					position: results[0].geometry.location
				});
				my_markers.push (marker);
			}
		});
	}
	google_maps_init_{{map_id}} ();
});
</script>
