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

Error handling for Live calculation of BingMaps Distance and Time based on user input

Hi All,

I have an edit form view that takes into 2 locations - Vendor Address and Destination. Based on the user input, it will calculate the distance and time live in the distance (km) and estimated duration (mins) fields. The form works. However, it throws up an error because calculation of distance and time fails before the user could complete inputting the location fields. Are there any ways to disable the error?

Alois_0-1603812577531.png
Regards,
Alois

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Alois ,

The reason why you met this problem is that:

before you finish entering location in that two textinputs, BingMaps.GetRoute function have started to calculate location based on data in these two textinputs.

Since you haven't finished entering location, so BingMaps.GetRoute could not get right location.

 

To add this problem I suggest you add a justification by using BingMaps.GetLocationByPoint function or BingMaps.GetLocationByAddress function.

 

Could you tell me whether you enter Address or Point in DataCardValue56 and DataCardValue60?

If you enter  Address, you could use formula like this:

If(
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput1.Text}))&&
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput2.Text})),
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

If you enter  Point, you could use formula like this:

If(
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue56.Text,",")).Result,
                                      Last(Split(DataCardValue56,",")).Result
                                      )
         )&&
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue60.Text,",")).Result,
                                      Last(Split(DataCardValue60,",")).Result
                                      )
         )
,
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

4 REPLIES 4
Super User III
Super User III

Hi @Alois 

One way to avoid this error is to only calculate the distance if the input values are not blank.

You would change your formula as follows..

 

If(DataCardValue56.Text <> "" && DataCardValue60.Text <> "",
   Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2),
   0
)

Hi @timl,
It returns me an error in evaluating the expression. Am I doing it right? 

The reference to datacardvalue are correct.

Alois_0-1603846084117.png

Regards,
Alois

 

Hi @Alois ,

The reason why you met this problem is that:

before you finish entering location in that two textinputs, BingMaps.GetRoute function have started to calculate location based on data in these two textinputs.

Since you haven't finished entering location, so BingMaps.GetRoute could not get right location.

 

To add this problem I suggest you add a justification by using BingMaps.GetLocationByPoint function or BingMaps.GetLocationByAddress function.

 

Could you tell me whether you enter Address or Point in DataCardValue56 and DataCardValue60?

If you enter  Address, you could use formula like this:

If(
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput1.Text}))&&
!IsEmpty(BingMaps.GetLocationByAddress({addressLine:TextInput2.Text})),
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

If you enter  Point, you could use formula like this:

If(
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue56.Text,",")).Result,
                                      Last(Split(DataCardValue56,",")).Result
                                      )
         )&&
!IsEmpty(
          BingMaps.GetLocationByPoint(First(Split(DataCardValue60.Text,",")).Result,
                                      Last(Split(DataCardValue60,",")).Result
                                      )
         )
,
Round(BingMaps.GetRoute(DataCardValue56.Text, DataCardValue60.Text).travelDistance,2)
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
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

Hi @v-yutliu-msft ,

The solution worked but was shortlived. Users were complaining of errors popping up as they keyed in the addresses. It seems like BingMaps continues to actively calculate the distance and duration despite having accounted for the if !empty cases.

Alois_0-1605607667819.png

Do you (or anyone) have any idea the reason for this and how to circumvent it?

Regards,
Alois

 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (3,607)