﻿function initializeGoogleMap(mapCanvasID, mapCenterLatitude, mapCenterLogitude, zoomLevel) 
{
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById(mapCanvasID));
		map.setCenter(new GLatLng(mapCenterLatitude, mapCenterLogitude), zoomLevel);
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//map.enableScrollWheelZoom();
		map.enableGoogleBar();

		return map;
	}
	else
	{
		return null;
	}
	
//	var growers = new GLatLng(mapCenterLatitude, mapCenterLogitude);
//      panoramaOptions = { latlng:growers };
//      myPano = new GStreetviewPanorama(document.getElementById("pano"), panoramaOptions);
//      GEvent.addListener(myPano, "error", handleNoFlash);
}

function initializeGoogleStreetView(streetViewCanvasID, streetViewCenterLatitude, streetViewCenterLogitude) 
{
	var googleStreetViewLatLng = new GLatLng(streetViewCenterLatitude, streetViewCenterLogitude);
	var panoramaOptions = { latlng:googleStreetViewLatLng };
	var myGoogleStreetView = new GStreetviewPanorama(document.getElementById(streetViewCanvasID), panoramaOptions);
    GEvent.addListener(myGoogleStreetView, "error", handleNoFlash);
}

function handleNoFlash(errorCode) 
{
	if (errorCode == FLASH_UNAVAILABLE) 
	{
		alert("Error: Flash doesn't appear to be supported by your browser");
		return;
	}
}  

function addPointToGoogleMap(map, latitude, longitude, markerIcon, title, message)
{
	var markerOptions = { icon:markerIcon, title:title };
	var marker = new GMarker(new GLatLng(latitude, longitude), markerOptions);
	
	GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("<span style='font-family:Arial,Helvetica,sans-serif; font-size:12px;'>" + message + "</span>"); });
	
	map.addOverlay(marker);
	
	return marker;
}

//http://econym.googlepages.com/geicons.htm

var houseGoogleMapIcon;
	houseGoogleMapIcon = new GIcon();
	houseGoogleMapIcon.image = "http://maps.google.com/mapfiles/kml/pal3/icon56.png";
	houseGoogleMapIcon.shadow = "http://maps.google.com/mapfiles/kml/pal3/icon56s.png";
	houseGoogleMapIcon.iconSize = new GSize(32, 32);
	houseGoogleMapIcon.shadowSize = new GSize(59, 32);
	houseGoogleMapIcon.iconAnchor = new GPoint(14, 28);
	houseGoogleMapIcon.infoWindowAnchor = new GPoint(15, 5);
	houseGoogleMapIcon.infoShadowAnchor = new GPoint(23, 55);	
	
var redGoogleMapIcon;
	redGoogleMapIcon = new GIcon();
	redGoogleMapIcon.image = "http://maps.google.com/mapfiles/kml/pal4/icon49.png";
	redGoogleMapIcon.shadow = "http://maps.google.com/mapfiles/kml/pal4/icon49s.png";
	redGoogleMapIcon.iconSize = new GSize(32, 32);
	redGoogleMapIcon.shadowSize = new GSize(59, 32);
	redGoogleMapIcon.iconAnchor = new GPoint(14, 28);
	redGoogleMapIcon.infoWindowAnchor = new GPoint(15, 5);
	redGoogleMapIcon.infoShadowAnchor = new GPoint(23, 55);	
	
var airportGoogleMapIcon;
	airportGoogleMapIcon = new GIcon();
	airportGoogleMapIcon.image = "http://maps.google.com/mapfiles/kml/pal2/icon56.png";
	airportGoogleMapIcon.shadow = "http://maps.google.com/mapfiles/kml/pal2/icon56s.png";
	airportGoogleMapIcon.iconSize = new GSize(32, 32);
	airportGoogleMapIcon.shadowSize = new GSize(59, 32);
	airportGoogleMapIcon.iconAnchor = new GPoint(14, 28);
	airportGoogleMapIcon.infoWindowAnchor = new GPoint(15, 5);
	airportGoogleMapIcon.infoShadowAnchor = new GPoint(23, 55);	
	
// : http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAIIAkNwomJuGBvtlocvANJhRPZgOMvSW0S3NEKsVh0t3bXgVoBBTugc1ox054f-OQXSTDlbrOlqVs_w

