Hi im trying to calculate the distance using the longitude and latitude between two points and display it how do i do this on javascript???
Hi im trying to calculate the distance using the longitude and latitude between two points and display it how do i do this on javascript???
Hi Jackson,
Please take a look at here:
https://getsatisfaction.com/apperyio/...
Hi Katya, how do i change the code so that i can display the distance on a label and call on this function?
Jackson,
Add the function described above as a JavaScript asset, then run the following JavaScript code when needed:
codeAppery( "mobilelabel_result" ).val( distance(
Appery( "mobilelabel_from_lat" ).val(), Appery( "mobilelabel_from_long" ).val(),
Appery( "mobilelabel_to_lat" ).val(), Appery( "mobilelabel_to_long" ).val()
) );/code
Hi Katya, I have followed the instructions but it doesnt seem to work. I copied and pasted the code on a javascript file and named it 'test'. I then tried to execute the function with the code u just provided using a button.
and renamed it to the following code:
Appery( "mobilelabel_result" ).val( distance(
Appery( "latitude" ).val(), Appery( "longitude" ).val(),
Appery( "lat_test1" ).val(), Appery( "long_test2" ).val()
) );
'latitude' and 'longitude' is my current locations position.
'lat_test1' and 'long_test2' was a random position
all four values were in an input box.
Hello!
1) If you saves result in Label you need to use codeAppery( "mobilelabel_result" ).text/code instead codeAppery( "mobilelabel_result" ).val/code
2) What are 'latitude', 'longitude', 'lat_test1' and 'long_test2' components?
if they are Inputs - then the code is correct, if they are Labels - use method text instead of val
3) try this code:
codeAppery( "mobilelabel_result" ).text( distance(
+Appery( "latitude" ).val(), +Appery( "longitude" ).val(),
+Appery( "lat_test1" ).val(), +Appery( "long_test2" ).val()
) );/code
unary plus converts a string to a number.
Hi Marina, that worked perfectly thank you very much. However i forgot to mention that for the distance i want it to be in km not in miles since my country doesnt use miles. So for the code Katya had provided for me what do i need to change to make the function calculate in terms of km.
Hi Jackson,
Then you can remove the division by the number of kilometers to miles ratio: code/ 1.60933966531/code
Thank you Katya and Marina!
How do i round it to two decimal places. its giving me like 85.08850817788226 .