function GetDistance( lat1,  lng1,  lat2,  lng2){
var radLat1 = lat1 * Math.PI / 180.0
var radLat2 = lat2 * Math.PI / 180.0
var a = (lat1 - lat2) * Math.PI / 180.0;
var b = (lng1 - lng2) * Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2)));
s = s * 6378137 ;// EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s;
}

Js算两经纬度间球面距离的更多相关文章

  1. 【Python】用geopy查两经纬度间的距离

    代码: from geopy.distance import vincenty from geopy.distance import great_circle 天安门 = (39.90733345, ...

  2. js计算两经纬度之间的距离

    js如下: // 方法定义 lat,lng function GetDistance( lat1, lng1, lat2, lng2){    var radLat1 = lat1*Math.PI / ...

  3. C# JackLib系列之如何获取地球上两经纬度坐标点间的距离

    获取地球上两经纬度坐标点间的距离,利用[大圆距离公式]   A diagram illustrating great-circle distance (drawn in red) between tw ...

  4. js判断输入字符串长度(汉字算两个字符,字母数字算一个)

    js判断输入字符串长度(汉字算两个字符,字母数字算一个) 文本输入时,由于数据库表字段长度限制会导致提交失败,因此想到了此方法验证. 废话不多说上代码: <html> <head&g ...

  5. js判断字符长度 汉字算两个字符

    方法一:使用正则表达式,代码如下: function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { ...

  6. 常见的js算法面试题收集,es6实现

    1.js 统计一个字符串出现频率最高的字母/数字 let str = 'asdfghjklaqwertyuiopiaia'; const strChar = str => { let strin ...

  7. 《Entity Framework 6 Recipes》中文翻译系列 (10) -----第二章 实体数据建模基础之两实体间Is-a和Has-a关系建模、嵌入值映射

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 2-11 两实体间Is-a和Has-a关系建模 问题 你有两张有Is-a和Has-a ...

  8. js保留两位小数

    js保留两位小数四舍五入: (Math.floor(until_price*100)/100).toFixed(2);//会四舍五入   保留两位小数 且不四舍五入(三种方式,请用最后一种): var ...

  9. js中两个对象的比较

    代码取自于underscore.js 1.8.3的isEqual函数. 做了一些小小的修改,主要是Function的比较修改. 自己也加了一些代码解读. <!DOCTYPE html> & ...

随机推荐

  1. Python pip install Twisted 出错“Command "c:\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:...\\Twisted\\setup.py'.... failed with error code 1 in C:... \\Twisted"

    如标题所说: python版本是目前最新的3.7.1 结果发现并不是环境问题,而是直接 pip install Twisted 安装的包不兼容 需要手动下载兼容的扩展包Twisted-18.9.0-c ...

  2. web.py学习遇到的问题

    刚配置好了web.py运行所需要的环境,试着运行一个入门小实例,结果遇到了异常提示.不知道是什么原因导致的(是环境没配置好?还是……),暂时做个标记,记录一下. 运行的代码 import web ur ...

  3. json.Decoder vs json.Unmarshal

    128down voteaccepted It really depends on what your input is. If you look at the implementation of t ...

  4. 利用Python读取文件名并生成txt文件——以图片文件为例

    效果如下: 代码: import os class ReadImageName(): def __init__(self): self.path = '.' def readname(self): f ...

  5. Spring 读取配置文件(一)

    注册 @Configuration 标识的类,spring 读取配置文件的时候该类会被自动装载 package cn.com.receive;import org.springframework.be ...

  6. Nginx编译安装第三方模块http_substitutions_filter_module2222

    Nginx编译安装第三方模块http_substitutions_filter_module Rming -- 阅读 安装 Http 编译 module filter nginx 模块 >> ...

  7. AngularCSS 的引入: CSS On-Demand for AngularJS

    1) Include the required JavaScript libraries in your index.html (ngRoute and UI Router are optional) ...

  8. 使用pycharm手动搭建python语言django开发环境(四) django中buffer类型与str类型的联合使用

    在django中,如果用到buffer类型时,buffer的编码格式是utf-8类型.使用str()进行转为字符串类型会异常. 异常会有如下提示:'ascii' codec can't decode ...

  9. iOS_25_彩票骨架搭建+导航栏适配

    终于效果图: Main.storyboard 初始化的控制器是:导航控制器 它的根控制器是:TabBarController TabBarController的底部是一个自己定义的TabBar 里面加 ...

  10. LeetCode581. Shortest Unsorted Continuous Subarray

    Description Given an integer array, you need to find one continuous subarray that if you only sort t ...