{"id":617,"date":"2011-11-08T09:54:59","date_gmt":"2011-11-08T09:54:59","guid":{"rendered":"http:\/\/mahenderpal.wordpress.com\/?p=617"},"modified":"2011-11-08T09:54:59","modified_gmt":"2011-11-08T09:54:59","slug":"step-by-step-integrating-bing-maps-in-ms-crm-2011","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=617","title":{"rendered":"Step By Step integrating Bing Maps in MS CRM 2011"},"content":{"rendered":"<p style=\"text-align:left;\">In this post I am going to show, how easily we can integration bingmap in MS CRM 2011. I am going to create a html webresource which will show account\u2019s city location on bing maps based on city address.<\/p>\n<p>Here are the steps to implement the same<\/p>\n<ol>\n<li>First steps is to get <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ff428642.aspx\">Bingmap developers key<\/a>.<\/li>\n<li>Create an html page and use below code in this page and save that page. (you can put this page in intpub location and can test this in your browser, in that case you need to hardcode city value).<\/li>\n<\/ol>\n<p>&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>\u00a0\u00a0 &lt;head&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;title&gt;&lt;\/title&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=utf-8&#8243;&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;http:\/\/ecn.dev.virtualearth.net\/mapcontrol\/mapcontrol.ashx?v=7.0&#8243;&gt;&lt;\/script&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;script type=&#8221;text\/javascript&#8221;&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var map = null;<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 function GetMap() {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Initialize the map<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map = new Microsoft.Maps.Map(document.getElementById(&#8220;mapDiv&#8221;), { credentials: &#8220;Your BingMap Key&#8221;, mapTypeId: Microsoft.Maps.MapTypeId.road });<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 function ClickGeocode(credentials) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.getCredentials(MakeGeocodeRequest);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 function MakeGeocodeRequest(credentials) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/Get City value from MS CRM account\u2019s form<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var geocodeRequest = &#8220;http:\/\/dev.virtualearth.net\/REST\/v1\/Locations\/&#8221; + <strong>window.parent.Xrm.Page.getAttribute(&#8216;address1_city&#8217;).getValue()<\/strong> + &#8220;?output=json&amp;jsonp=GeocodeCallback&amp;key=&#8221; + credentials; \/\/make sure to replace field name if you are using custom field.<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 CallRestService(geocodeRequest);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 function GeocodeCallback(result) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (result &amp;&amp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 result.resourceSets &amp;&amp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 result.resourceSets.length &gt; 0 &amp;&amp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 result.resourceSets[0].resources &amp;&amp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 result.resourceSets[0].resources.length &gt; 0) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Set the map view using the returned bounding box<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var bbox = result.resourceSets[0].resources[0].bbox;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var viewBoundaries = Microsoft.Maps.LocationRect.fromLocations(new Microsoft.Maps.Location(bbox[0], bbox[1]), new Microsoft.Maps.Location(bbox[2], bbox[3]));<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.setView({ bounds: viewBoundaries });<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var location = new Microsoft.Maps.Location(result.resourceSets[0].resources[0].point.coordinates[0], result.resourceSets[0].resources[0].point.coordinates[1]);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var pushpin = new Microsoft.Maps.Pushpin(location);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 map.entities.push(pushpin);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 function CallRestService(request) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 var script = document.createElement(&#8220;script&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 script.setAttribute(&#8220;type&#8221;, &#8220;text\/javascript&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 script.setAttribute(&#8220;src&#8221;, request);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 document.body.appendChild(script);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>&nbsp;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/script&gt;<\/p>\n<p>\u00a0\u00a0 &lt;\/head&gt;<\/p>\n<p>\u00a0\u00a0 &lt;body onload=&#8221;GetMap();ClickGeocode();&#8221;&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;div id=&#8217;mapDiv&#8217; style=&#8221;position:relative; width:400px; height:400px;&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>\u00a0\u00a0 &lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>3.\u00a0 Create a HTML webresource and upload your html page here.<\/p>\n<p><a href=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/bingwebresource.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-618\" title=\"BingWebResource\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/bingwebresource.png?w=300\" alt=\"\" width=\"300\" height=\"194\" \/><\/a><\/p>\n<p>4. Open account form and Create a new Tab let&#8217;s say Accountlocation.<\/p>\n<p>5. Add a new webresource\u00a0and browse your webresource from web resource lookup.<\/p>\n<p><a href=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/formwebresource.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-621\" title=\"formwebresource\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/formwebresource.png?w=300\" alt=\"\" width=\"300\" height=\"279\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>6. Save and publish your form.<\/p>\n<p>7. Open any account record and check for Account location tab.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter\" title=\"city\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/city.png?w=300\" alt=\"\" width=\"300\" height=\"21\" \/><\/p>\n<p><a href=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/citylocation.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-619\" title=\"Citylocation\" src=\"http:\/\/mahenderpal.files.wordpress.com\/2011\/11\/citylocation.png?w=300\" alt=\"\" width=\"300\" height=\"257\" \/><\/a><\/p>\n<p>Enjoy !!!<\/p>\n<p>Reference : <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dd877180.aspx\">Bing Maps SDK<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post I am going to show, how easily we can integration bingmap in MS CRM 2011. I am going to create a html webresource which will show account\u2019s city location on bing maps based on city address. Here are the steps to implement the same First steps is to get Bingmap developers key. Create an html page and&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=617\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,19],"tags":[],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/617"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=617"}],"version-history":[{"count":0,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/617\/revisions"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}