Google Maps Integration with Dynamics CRM

MS Dynamics CRM by default is integrated with Bing maps. You can add Bing maps on any entity you want. You can enable or disable the feature in the Settings > Administration > System Settings area.

But if you want to integrate Google maps in Dynamics CRM on Accounts and Contacts entities, you can do so by adding a HTML web resource on account and contact forms.

Step 01: Add HTML Web Resource

In order to add Google map HTML web resource go to Settings > Customizations > Customize the system

customization

Click on Web Resources and then New

add webresource

and fill out the form for adding a new web resource;

Name – googlemaps
Display Name – Google Maps
Type – HTML
Text Editor – Click on text editor and paste the code given below;

<html>

<head>
<script>
function initialize() {
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: new google.maps.LatLng(-26.4420246,133.281323),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(map_canvas, map_options)
var geocoder = new google.maps.Geocoder();
var address = window.parent.Xrm.Page.data.entity.attributes.get('address1_composite').getValue();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
map.setZoom(14);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
//alert("Geocode was not successful for the following reason: " + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div style="width: 100%; height: 100%;" id="map_canvas"></div>
</body>
</html>

googlemap

texteditor

Save – Save the Web Resource
Publish – Publish the Web Resource
Preview – In the preview you will see Australia is set as default map location for cases where Address 1 fields arent populated on a record.

preview

Step 02: Add Map on Account form

Go to Account form and click on Form in the ribbon

account

Next click on Insert in the navigation and insert a new Section on form

insert

Double click on the section and rename it to Google Map.

google-mapNext add HTML web resource in this section. Select the section and click on Webreource in the ribbon

select section

Click on Web Resource in the ribbon and search the web resource we added

search webresource

When you have found the web resource, click on Add

add

Now go to Formatting tab and extend Number of Rows for this section in which the map will be displayed and click on OK.

rows

Step 03: Publish the form

Publish the form and click on Save and Close.

publish

Refresh Account form and you will find Google Map section. If correct address has been entered in Address 1 fields then the map will present Address 1 else the map will show Australia by default.

map preview

Note: Google map HTML web resource has been taken from Warren Rapson’s blog post. You can view his post here

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s