/*
code to initialize a google map.
To find the longitude/latitude pass nulls in their place, navigate to the right position, and click the map. 
 */
function initialize(mapID, latitude, longitude, markerText) {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById(mapID));
		if(longitude==null || latitude==null) {
			longitude=43.670;
			latitude=-79.386;
			
			GEvent.addListener(map, "click", function() {
				alert('map center is: ' + map.getCenter().toString());
			});
		}
		var point = new GLatLng(longitude, latitude);
		map.setCenter(point, 13);
		map.setUIToDefault();
		
		var marker = new GMarker(point);
		map.addOverlay(marker);
		if(markerText!=null) {
			marker.openInfoWindowHtml(markerText);
		}
		
		//var geocoder = new GClientGeocoder();
		//showAddress(map, geocoder,  '2680 Matheson Blvd. East, Mississauga, ON, Canada');


	}
}


function showAddress(map, geocoder, address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert(address + " not found");
      } else {
        map.setCenter(point, 13);
        var marker = new GMarker(point);
        map.addOverlay(marker);
        marker.openInfoWindowHtml(address + '<br>' + point.x + ' ' + point.y);
      }
    }
  );
}


