web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Adding a Google map to contacts and accounts

(0) ShareShare
ReportReport
Posted on by 100

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

 

*This post is locked for comments

I have the same question (0)
  • Zaxxon Profile Picture
    100 on at

    been nearly 2 month, and no replies...

    Can anyone help?

  • Jamie P Profile Picture
    575 on at

    I don't know all the ins and outs, but you would only need to use an iFrame on the forms view.  An iFrame is used to bring in outside data such as sharepoint or a map.  I think a little coding is needed to pass the address to it, but it didn't look hard last time I looked it.

     Hope this helps.

    -JP

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans