Forum Discussion
Calculate the distance between 2 locations (latitude & Latitude) using BingMaps.GetRouteV2
I have an Asset with latitude & Latitude and i am getting it using this formula:-
Set(relatedAsset,LookUp(Assets,ID=LookUp('Asset Faces',ID= LookUp('ticket Details',ID=If(IsBlank(varticketID),varNavigationID,varticketID)).'Asset Face ID').'Asset ID'));
then i am getting the latitude & Latitude of the current technicians from SharePoint list as follow:-
ClearCollect(colRelatedticketTechnicianLocation,Filter('Technicians Locations','ticket ID'=If(IsBlank(varticketID),varNavigationID,varticketID)));
add a column to the collection:-
AddColumns(colRelatedticketTechnicianLocation,"Distance",0);
then i am trying to Forall the items inside the collection and calculate the distance between the Asset and the Technician:-
ForAll(colRelatedticketTechnicianLocation As ticketLocation, Patch(colRelatedticketTechnicianLocation,LookUp(colRelatedticketTechnicianLocation,ID=ticketLocation.ID),{Distance: BingMaps.GetRouteV2()}); Blank() )
but currently i am facing these 2 issues:-
1) i am not sure how to pass the source and distention latitude & Latitude inside the BingMaps.GetRouteV2 method?
2) inside the final statement , i am getting that it can not find a column named Distance, although i added it using the Addcolumns, any advice?
Thanks
- Rob_ElliottBronze Contributor
johnjohn-Peter for your last point make sure you have refreshed the datasource in your app. For my app, I got the distance using the following:
Set(distance, BingMaps.GetRoute((txtStartStreet.Text&", "&txtStartTown.Text), (txtEndStreet.Text&", "&txtEndTown.Text), {distanceUnit: "Mile" }))Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP (and classic 1967 Morris Traveller driver)- johnjohn-PeterIron Contributor
Rob_Elliott Thanks for the reply, do you know how to pass Latitude and Longitude instead of street names? i can not find any relevant documentations regarding this . thanks