cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
axel_BI
Frequent Visitor

BingMaps.GetRoute()

Hello everybody,

 

im trying to minimize the distance on a route between different Shops.

These are stored in a unsorted Galllery, where i got the attributes latitude and longitude.

 

1) I concatenate the lat/lon for each record with a "," in between

2) Then i concat these (lat,lon) with a ";" in between
3) i receive a string with this format "(lat,lon);(lat,lon);...;(lat,lon)"
4) i want to pass this string into the GetRoute-Method, but as it is only receiving one parameter (the string) it throws an error

5) how will the method recognize, that the string contains multiple locations

 

BingMaps.GetRoute(
    Text(Concat(Gallery.AllItems;
Concatenate('Shop latitude';",";'shop longitude');
"; ")
)
).distance
 
Thank you for any ideas
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Re: BingMaps.GetRoute()

Hi @axel_BI ,

The BingMaps.GetRoute() function could only calculate a route based on two different waypoints. It could not be used to calculate the route based on multiple waypoints.

 

If you want to get the minimized distance using the BingMaps.GetRoute() function based on multiple waypoints (> 2), I afraid that there is no way to achieve your needs in PowerApps currently.

 

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

If the waypoints that you mentioned is not more than 25 (the amount of Gallery items is not more than 25), I think the Bing Map Static Imagery Rest API could achieve your needs. I have made a test on my side, please check the following workaround:

3.JPG

 

On your side, you could consider add a Button (called "Re-Calculate Route") within your app, set the OnSelect property to following:

Clear(WayPointCollection);
ForAll(
       Gallery.AllItems,
       Collect(
               WayPointCollection,
               {
                 Index: CountRows(WayPointCollection),
                 Latitude: 'Shop latitude',
                 Longitude: 'Shop longitude'
               }
       )
)

Then add a Image control within your app, set the Image property to following:

"https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?" &
Concat(
       WayPointCollection,
       "wp."& Index & "=" & Latitude & "," & Longitude & "&"
) &
"optimize=distance&distanceUnit=km&mapSize="& App.Width & "," & App.Height &"&key=Type your Bing Map Key Here"

then when press the "Re-Calculate Route" button, the route would be displayed within the Image control.

 

More details about displaying Bing Map using a Image control, please check the following blog:

https://powerapps.microsoft.com/en-us/blog/image-control-static-maps-api/

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
axel_BI
Frequent Visitor

Re: BingMaps.GetRoute()

Seems no Solution possible, as the route can only be optimized for 2 locations. But i need to make a route for an unknown number <2

Community Support
Community Support

Re: BingMaps.GetRoute()

Hi @axel_BI ,

The BingMaps.GetRoute() function could only calculate a route based on two different waypoints. It could not be used to calculate the route based on multiple waypoints.

 

If you want to get the minimized distance using the BingMaps.GetRoute() function based on multiple waypoints (> 2), I afraid that there is no way to achieve your needs in PowerApps currently.

 

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

 

If the waypoints that you mentioned is not more than 25 (the amount of Gallery items is not more than 25), I think the Bing Map Static Imagery Rest API could achieve your needs. I have made a test on my side, please check the following workaround:

3.JPG

 

On your side, you could consider add a Button (called "Re-Calculate Route") within your app, set the OnSelect property to following:

Clear(WayPointCollection);
ForAll(
       Gallery.AllItems,
       Collect(
               WayPointCollection,
               {
                 Index: CountRows(WayPointCollection),
                 Latitude: 'Shop latitude',
                 Longitude: 'Shop longitude'
               }
       )
)

Then add a Image control within your app, set the Image property to following:

"https://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Routes?" &
Concat(
       WayPointCollection,
       "wp."& Index & "=" & Latitude & "," & Longitude & "&"
) &
"optimize=distance&distanceUnit=km&mapSize="& App.Width & "," & App.Height &"&key=Type your Bing Map Key Here"

then when press the "Re-Calculate Route" button, the route would be displayed within the Image control.

 

More details about displaying Bing Map using a Image control, please check the following blog:

https://powerapps.microsoft.com/en-us/blog/image-control-static-maps-api/

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

axel_BI
Frequent Visitor

Re: BingMaps.GetRoute()

Thanks for your detailed Input, works like a charm

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,554)