{"id":3990,"date":"2020-10-12T06:48:12","date_gmt":"2020-10-12T06:48:12","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=3990"},"modified":"2020-10-13T05:09:57","modified_gmt":"2020-10-13T05:09:57","slug":"canvas-app-with-bing-maps-in-dynamics-365-ce-2","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=3990","title":{"rendered":"Canvas app with Bing Maps in Dynamics 365 CE -2"},"content":{"rendered":"<p><strong>Introduction<\/strong><br \/>\nThis is second article about using Bing maps in Canvas app. In the first article we discussed about how we can show event organizer data in the gallery control and render them in the Bing maps. In this article we are going to show event as well as event organization details in Bing maps.<\/p>\n<p><strong>Details<\/strong><br \/>\nIn last app we rendered event organizations in the Bing maps but now let&#8217;s say we also want to show event location with event organizations. To show event location over map we need to add geo coordinates to event entity (Latitude and Longitude), so let&#8217;s modify our event entity and add some other address field and latitude and longitude like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_1.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3994 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_1-300x170.jpg\" alt=\"part2_1\" width=\"300\" height=\"170\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_1-300x170.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_1.jpg 619w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Once we have added this field we need to add some logic to get geo coordinates based on the address details. We can create a simple Power Automate to get these details using following steps.<\/p>\n<p>1. Navigate to Power Automate from your subscriptions, click on Create to create automated Flow<br \/>\n2. Select Common Data Service connector and select below trigger<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_2.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3995 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_2-300x142.jpg\" alt=\"part2_2\" width=\"300\" height=\"142\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_2-300x142.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_2-624x296.jpg 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_2.jpg 900w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n3. Configuration start step for your flow<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_3.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3996 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_3-300x141.jpg\" alt=\"part2_3\" width=\"300\" height=\"141\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_3-300x141.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_3.jpg 593w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n4. Search for Bing maps connector and select get location by address action, we need to pass address details to get latitude and longitude<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_4.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3997 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_4-300x200.jpg\" alt=\"part2_4\" width=\"300\" height=\"200\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_4-300x200.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_4.jpg 607w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n5. Next add steps to update these details to event entity like following<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_5.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3998 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_5-300x248.jpg\" alt=\"part2_5\" width=\"300\" height=\"248\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_5-300x248.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_5.jpg 498w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n6. Save your changes and test your flow to make sure it getting details after event record created.<\/p>\n<p>Now we have geocoordinates of the event location, let&#8217;s change our canvas app.<\/p>\n<p>Open canvas app in edit mode and drag Reload icon and place on the title bar like below<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_6.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-3999 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_6-300x265.jpg\" alt=\"part2_6\" width=\"300\" height=\"265\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_6-300x265.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_6.jpg 456w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Now we need to add following code in OnSelect event of the icon<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/Create new collection of event and event organizer\r\nUpdateContext(\r\n    {\r\n        eventwitheventorgCol: Concatenate(\r\n            eventorganizersCol,\r\n            &quot;&amp;pp=&quot;,\r\n            Text(ModelDrivenFormIntegration.Item.Latitude),\r\n            &quot;,&quot;,\r\n            Text(ModelDrivenFormIntegration.Item.Longitude),\r\n            &quot;;&quot; &amp; &quot;129&quot; &amp; &quot;;&quot;\r\n        )\r\n    }\r\n);\r\n\/\/create a variable mapURL to set it to image control\r\nSet(\r\n    mapURL,\r\n    &quot;https:\/\/dev.virtualearth.net\/REST\/v1\/Imagery\/Map\/Road?mapSize=650,400&quot; &amp; eventwitheventorgCol &amp; &quot;&amp;zoomlevel=14&quot; &amp; &quot;&amp;key=BINGMapKey&quot;\r\n);\r\n\/\/refresh form\r\nModelDrivenFormIntegration.RefreshForm(false);\r\n<\/pre>\n<p>In the first express we are combining our existing eventorganizersCol with we created in our part1 with the event details. To get event details we are using ModelDrivenFormIntegration control which will provide us details of the current record, we can consider this control just like executioncontext we use in entity forms to get context information. You can get more details about this control from <a href=\"https:\/\/docs.microsoft.com\/en-us\/powerapps\/maker\/model-driven-apps\/embedded-canvas-app-properties-actions\">here<\/a>. To get current record fields we can simple use following option of this control<\/p>\n<p><strong>ModelDrivenFormIntegration.Item.FieldDisplayName <\/strong><\/p>\n<p>We are concatenating event organization details with event and using 129 (push pin icon style) to show event location. Next we are creating a variable to hold Bing maps static url which will be using under the image property of image control.<\/p>\n<p>Set(<br \/>\nmapURL,<br \/>\n&#8220;https:\/\/dev.virtualearth.net\/REST\/v1\/Imagery\/Map\/Road?mapSize=650,400&#8221; &amp; eventwitheventorgCol &amp; &#8220;&amp;zoomlevel=14&#8221; &amp; &#8220;&amp;key=Bingmap key&#8221;<br \/>\n);<\/p>\n<p>We can change our old code where we are showing event organization similarly to have url for the event organizers.<\/p>\n<p>Finally we set this variable under image control<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_7.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4000\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_7-300x65.jpg\" alt=\"part2_7\" width=\"300\" height=\"65\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_7-300x65.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_7.jpg 432w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Finally Save and publish our app. Now we will create event record we will be able to see map like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_8.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4001 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_8-300x157.jpg\" alt=\"part2_8\" width=\"300\" height=\"157\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_8-300x157.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_8-624x326.jpg 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_8.jpg 746w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>And if we want to see Event location with event organizations we can click on the Reload icon and it will show both details like below:<br \/>\n<a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_9.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4002 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_9-300x176.jpg\" alt=\"part2_9\" width=\"300\" height=\"176\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_9-300x176.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_9-624x367.jpg 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2020\/10\/part2_9.jpg 771w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/?p=3967\"><strong>Canvas app with Bing Maps in Dynamics 365 CE -1<\/strong><\/a><\/p>\n<p><strong>Summary<\/strong><br \/>\nThis is how we can get geocoordinates using simple Power Automate and show two entity details in the Bing maps.<\/p>\n<p>We will be doing some more changes to our demo app so stay tuned!.<\/p>\n<p>Hope it will help someone!<br \/>\n<strong>Keep learning, Keep sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction This is second article about using Bing maps in Canvas app. In the first article we discussed about how we can show event organizer data in the gallery control and render them in the Bing maps. In this article we are going to show event as well as event organization details in Bing maps. Details In last app we&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=3990\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":4002,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[817,21,593,728],"tags":[830,827,828,826,829],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3990"}],"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=3990"}],"version-history":[{"count":8,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3990\/revisions"}],"predecessor-version":[{"id":4015,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3990\/revisions\/4015"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/4002"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}