cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MSC01
Helper I
Helper I

BingMaps.GetRoute - calculate distance and duration in 1 request

Hi,

 

i am using Bingmaps.GetRoute in a label within a gallery (as i have to calculate distance and duration for multiple people listed in the gallery). I have currently got 2 separate BingMaps.GetRoute() labels - 1 for distance and 1 for duration. however this makes double the API call. I want to be able to retrieve the JSON in 1 call and use this 1 response to just show duration and distance either in 2 separate labels (ideally) or in 1 if needs be.

 

Thanks

6 REPLIES 6
v-xiaochen-msft
Community Support
Community Support

Hi @MSC01 ,

 

I did a test for you .

1\ This is my test collection 'Col'.

v-xiaochen-msft_0-1616652386631.png

 

2\ Add a gallery control and set its Items property to:

AddColumns(Col,"Test",BingMaps.GetRoute(A,B))

 

3\ Insert a label into gallery and set its Text property to:

ThisItem.Test.travelDistance

 

4\ Insert a label into gallery and set its Text property to:

ThisItem.Test.travelDuration

 

5\ The result is as follows:

v-xiaochen-msft_1-1616652506729.png

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

MSC01
Helper I
Helper I

Hi, the issue or what i think the issue is that my gallery is currently filtered by a drop down that the user selects from a list of options and this brings back users and their post code from CDS. How do i add the postcode labels to the collection- they will change according to the drop down option and the users in the list. Also how do i then use addcolumns with the filter on the gallery which is currently - filter('table' -from cds, name in combobox.selecteditems.name) as the user can select multiple options from the combo box

v-xiaochen-msft
Community Support
Community Support

Hi @MSC01 ,

 

Addcolumns() function can be used on cds directly , you don’t need to create another collection.

 

So, you could use this formula on Items property of gallery control.

Addcolumns(filter('table' -from cds, name in combobox.selecteditems.name),New Name,BingMaps.GetRoute(...,...) )

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

MSC01
Helper I
Helper I

 

MSC01_8-1616774290083.png

 



 

Hi, when i use a collection of the user postcode it brings it back in what seems to be a nested collection. 
The first image is what i see initially, followed by image 2 when i click into postc and if i click into any of the nested collections it shows the users post code under text. I just need the collection to retrieve the userpostcode which is the Text and destination, which i have no idea how to do. As shown below the post codes are currently listed in a gallery connected to cds table. The user can enter the destination which will be the same for all users in the gallery.

 

MSC01_9-1616774455626.png

 

 

 

v-xiaochen-msft
Community Support
Community Support

Hi @MSC01 ,

 

Please try ungroup() function.

For example:

This is my test collection.

v-xiaochen-msft_0-1616981492980.png

v-xiaochen-msft_1-1616981505362.png

v-xiaochen-msft_2-1616981517898.png

 

Use this formula:

Ungroup(Ungroup(Col3,"Haha"),"Test2")

 

The result is as follows:

v-xiaochen-msft_3-1616981583403.png

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

MSC01
Helper I
Helper I

thanks for the response, the ungroup worked just by using one ungroup(collection, "postcode"), however what do i do if there is more than 1 nested table to access and need to combine the data. 

MSC01_0-1617119588192.png

also if i try to do addcolumns to the filtered gallery, it doesnt work as i need to use the collection data with addcolumns . i want to be able to ideally use the collection data which gets the bingmaps data and bring it back to the same filtered gallery

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,209)