TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
anna levin
NA
19
1.6k
Calling a function within a function in Angular not work
Apr 20 2021 6:58 AM
I run the function calatuteRoute within which there is a call to the distanceBetweenToPointByDrive function But for some reason it did not enter the call of the distanceBetweenToPointByDrive function But straight skips to do the rest of the operations in the function calatuteRoute Anyone know what could be the problem? I would appreciate solutions.
Attached is the code:
app.component.ts
calatuteRoute() {
setTimeout(() => {
this
.distanceBetweenToPointByDrive(Destination.geometry.location.lat(),
Destination.geometry.location.lng(),
this
.arr[0].Lat_Destination,
this
.arr[0].Lng_Destination)
},3000)
//do more somthing..
}
distanceBetweenToPointByDrive(latExported: any, lngExported: any, LatDestination: any,
LngDestination: any): calculationResult {
const
resulte: calculationResult = {
distance:
""
,
time:
""
}
debugger
let pointX =
new
google.maps.LatLng(latExported, lngExported)
let pointY =
new
google.maps.LatLng(LatDestination, LngDestination)
const
service =
new
google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [pointX],
destinations: [pointY],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways:
false
,
avoidTolls:
false
,
},
(response, status) => {
if
(status !==
"OK"
) {
alert(
"Error was: "
+ status);
return
}
else
{
const
originList = response.originAddresses;
const
destinationList = response.destinationAddresses;
for
(let i = 0; i < originList.length; i++) {
const
results = response.rows[i].elements;
for
(let j = 0; j < results.length; j++) {
resulte.distance = results[j].distance.text;
resulte.time = results[j].duration.text;
}
}
}
return
resulte;
}
);
return
resulte;
}
Reply
Answers (
1
)
CKeditor not working correctly with custom directive
How to groupby in typescript