So i saw a demo by the fulks from CRM and in their account form they had a tab that had the map with a pinpoint on where the account was located. i looked on the web for ways to implement it and found a few solutions that seemed to be quite old and none worked for me or were too complex for me to implement with my limited skills. I eventually found a33ik blog http://a33ik.blogspot.com/2010/06/intergration-google-maps-v3-into.html where he has an example on how to integrate google maps with CRM, in essense the method is simple :
step 1. create an html page (i called it location.html) in which the following code is inserted
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Map integration</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var address = location.search;
address = address.substring(address.indexOf('=') + 1);
codeAddress(address);
}
function codeAddress(address) {
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
</script>
</head>
<body style="margin:0px; padding:0px;" onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
Step 2. Save this in a file with in C:\Inetpub\wwwroot\ISV
Then add a tab, section, and an iframe to the entity (I chose Contact).and add the following code in in the onload section:
crmForm.all.tab4Tab.onclick = function()
{
var url = "";
if (crmForm.all.address1_country.DataValue != null)
url = crmForm.all.address1_country.DataValue;
if (crmForm.all.address1_city.DataValue != null)
url += (url == "" ? "" : ", ") + crmForm.all.address1_city.DataValue;
if (crmForm.all.address1_name.DataValue != null)
url += (url == "" ? "" : ", ") + crmForm.all.address1_name.DataValue;
if (crmForm.all.address1_line1.DataValue != null)
url += (url == "" ? "" : ", ") + crmForm.all.address1_line1.DataValue;
if (crmForm.all.address1_line2.DataValue != null)
url += (url == "" ? "" : ", ") + crmForm.all.address1_line2.DataValue;
if (crmForm.all.address1_line3.DataValue != null)
url += (url == "" ? "" : ", ") + crmForm.all.address1_line3.DataValue;
if (url != "")
{
url = "/ISV/location.html?address=" + url;
crmForm.all.IFRAME_map.src = url;
}
}
And that should have done the trick - when i said simple - didnt mean it worked for me ;) .and thats the problem, its not working for me, i keep on getting an error about the gecode Geocode was not successful for the following reason: INVALID_REQUEST
Can any one spot what i am doing wrong, and help me get this running ?
Thanks in advance,
Zaxxon