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
Click on Web Resources and then New
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
>
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.
Step 02: Add Map on Account form
Go to Account form and click on Form in the ribbon
Next click on Insert in the navigation and insert a new Section on form
Double click on the section and rename it to Google Map.
Next add HTML web resource in this section. Select the section and click on Webreource in the ribbon
Click on Web Resource in the ribbon and search the web resource we added
When you have found the web resource, click on 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.
Step 03: Publish the form
Publish the form and click on Save and Close.
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.
Note: Google map HTML web resource has been taken from Warren Rapson’s blog post. You can view his post here
Hey, this is really a cool integration! But: How to enable, that an ‘on-click’ leads to the full google maps webpage? That would be the cherry on the cake!
When I preview the web resource all I get back is the HTML code not a map. Can you help figure out what I am missing. Used your code exactly as it is. thanks
If we want that the address of that particular account show that address location in map then what we do?
Please tell me as early as possible
I am trying to open this in my mobile app. But it is showing on mobile and if i click on that location it was opening on google maps. Is there any solution for this to open in mobile app.
Hi Naresh,
Google map location when clicked will by default open in the Google Map mobile application. Do you want to see the entire within CRM?
On click of the pinpoint I would like to open navigation, could you help us with that? I am looking to do this based on the Universal cross-platform syntax.
This way our account managers can navigate directly to the client from in app.
Thank you in advance!
Regards,
Bas