Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get nearest to user location js

function distance(lat1, lon1, lat2, lon2, unit) {
    var radlat1 = Math.PI * lat1/180
    var radlat2 = Math.PI * lat2/180
    var theta = lon1-lon2
    var radtheta = Math.PI * theta/180
    var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
    if (dist > 1) {
        dist = 1;
    }
    dist = Math.acos(dist)
    dist = dist * 180/Math.PI
    dist = dist * 60 * 1.1515
    if (unit=="K") { dist = dist * 1.609344 }
    if (unit=="N") { dist = dist * 0.8684 }
    return dist
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: implement dynamic import on event handler 
Javascript :: how to send email 
Javascript :: react native paper touchable ripple 
Javascript :: js react change slide by touch event 
Javascript :: translate from json string to object c# 
Javascript :: where to make the hooks functions 
Javascript :: downlaod file from website raect 
Javascript :: signing an msg.value transaction in ethersjs 
Javascript :: custu, loading next js 
Javascript :: loop with multiple conditions js codesmith 
Javascript :: array of function 
Javascript :: js decrypt online 
Javascript :: find a big length friend from array javascript finding longest string in array in javascript 
Javascript :: playwrigth await browser 
Javascript :: @rematch/loading 
Javascript :: Uncaught TypeError: document.getElementsByClassName(...).style is undefined 
Javascript :: react pdf fixed property not working 
Javascript :: ajax javascrit call by value method example 
Javascript :: javascript float not showing 0 
Javascript :: api call in react chart 
Javascript :: Promisify with ajax call 
Javascript :: hide header in next js page 
Javascript :: A Note about Floats 
Javascript :: reset default style javascript 
Javascript :: root emit with params 
Javascript :: jsx tag with children react js 
Javascript :: this 
Javascript :: trackpad scrolling detected multiple times 
Javascript :: initialize back4app 
Javascript :: gsheet calculate next tuesday date 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =