<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>MSCRM Google Map</title>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=<< Enter Key Here>>"
type="text/javascript"></script>
<script type="text/javascript">
var gMap = null;
var geocoder = null;
function initialize()
{
if (GBrowserIsCompatible())
{
var crmAddress = GetCRMAddress();
if(crmAddress != ',')
{
gMap = new GMap2(document.getElementById("MapHolder"));
//gMap.setCenter(new GLatLng(37.4419, -122.1419), 13);
geocoder = new GClientGeocoder();
LocateAddress(crmAddress);
}
else
{
DisplayMessage();
}
}
}
function LocateAddress(address)
{
if (geocoder)
{
geocoder.getLatLng(address,function(point)
{
if (!point)
{DisplayMessage();}
else
{
gMap.setCenter(point, 13);
var marker = new GMarker(point);
gMap.addOverlay(marker);
marker.openInfoWindowHtml(address);
}
}
);
}
}
function GetCRMAddress()
{
var schemaNames = 'address1_line1,address1_line2,address1_line3,address1_city, address1_stateorprovince,address1_country,address1_postalcode';
var schemaNameArray = schemaNames.split(",");
var address = '';
for(count = 0; count < schemaNameArray.length; count++)
{
var o = parent.document.getElementById(schemaNameArray[count]);
if(o != null)
{
if(o.value != '')
{
address = address + ',' + o.value ;
}
}
}
return address;
}
function DisplayMessage()
{
var lbl = document.getElementById('lblMessage');
lbl.style.display = "inline";
var div = document.getElementById('MapHolder');
div.style.display = "none";
}
</script>
</head>
<body>
<body onload="initialize()" onunload="GUnload()">
<form>
<div id="MapHolder" style="width: 700px; height: 350px">
</div>
<label id="lblMessage" style="display:none; font-family:@Arial Unicode MS; font-size:small; font-weight:bold; color:#15428b;">
Unable to locate the given address in Google Maps – Please update the address information and save the record then try again.</label>
</form>
</body>
</body>
</html>