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)

Web Resource Code for Google Maps reading Latitude/Longitude

(0) ShareShare
ReportReport
Posted on by

I spent a fair amount of time looking for this only to finally work out the code for online CRM. This is the code for a we resource that will load Google Maps reading off the Latitude and Longitude.

<html>
 <head>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta charset="utf-8">
  <style>
    html, body, #map-canvas {
      height: 100%;
      margin: 0px;
      padding: 0px
    }
  </style>
  <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
 </head>

 <body style="word-wrap: break-word;">
  <div id="map-canvas"></div>
  <script>
   var map;
   function initialize() {
    // Retrieve the values from Dynamics CRM
	var add1Lat = window.parent.Xrm.Page.getAttribute("address1_latitude").getValue();
    var add1Long = window.parent.Xrm.Page.getAttribute("address1_longitude").getValue();
    var add1Name = window.parent.Xrm.Page.getAttribute("address1_name").getValue();
    // Calculate the values and set options
	var myLatlng = new google.maps.LatLng(add1Lat, add1Long);
    var mapOptions = {
     zoom: 15,
     center: myLatlng
    }
    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    var marker = new google.maps.Marker({
     position: myLatlng,
     map: map,
     title: add1Name
    });
   }
   // Load the map
   google.maps.event.addDomListener(window, 'load', initialize);
  </script>
 </body>
</html>


*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    This is a slightly modified cut and paste job from various sources. The field names are standard so as long as your lat and long fields are populated this should work. Once you created the web resource insert it into your form and off you go.

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