Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get nearby store by latitude and longitude from my latitude and long node 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 }
    dist = parseFloat(dist.toFixed(4))
    return dist
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: (node:2496) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 
Javascript :: printf statement in javascript 
Javascript :: angular one array contains any of second 
Javascript :: express search query template 
Javascript :: append sibling javascript after first child 
Javascript :: discordjs delete all messages in channel 
Javascript :: modify margin top javascript 
Javascript :: what is global execution context in javascript 
Javascript :: how to count vowels in a string javascript 
Javascript :: return first letter of string javascript in uppercase 
Javascript :: system collections generic list to javascript array 
Javascript :: get the value or text from select element using javaScript 
Javascript :: javascript is JSON string valid 
Javascript :: replace regex javascript 
Javascript :: imagebackground in react native 
Javascript :: javascript stop delay 
Javascript :: javascript in line logic 
Javascript :: Using webpack 5. Reason: future.webpack5 option enabled https://nextjs.org/docs/messages/webpack5 
Javascript :: size of call stack js 
Javascript :: react native get navigation bar height 
Javascript :: jquery datatables get selected row data 
Javascript :: follow cursor javascript 
Javascript :: math.rount 
Javascript :: vue watch handler 
Javascript :: vue chart nuxt 
Javascript :: today in moment 
Javascript :: get element by class 
Javascript :: javascript round to nearest 10 
Javascript :: js image on canvas 
Javascript :: jquery key enter events 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =