• php计算经纬度间的距离


    <?php
    //根据经纬度计算距离
    function getdistance($lng1,$lat1,$lng2,$lat2)
    {
        //将角度转为狐度 
        $radLat1=deg2rad($lat1);
        $radLat2=deg2rad($lat2);
        $radLng1=deg2rad($lng1);
        $radLng2=deg2rad($lng2);
        $a=$radLat1-$radLat2;//两纬度之差,纬度<90
        $b=$radLng1-$radLng2;//两经度之差纬度<180
        $s=2*asin(sqrt(pow(sin($a/2),2)+cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)))*6378.137;
        return $s;
    }
    echo getdistance(116.30814954222,40.056885091681,116.30834954242,40.058895091681);

    php计算两个经纬度之间的距离,单位是米。

  • 相关阅读:
    AE旋转
    AE2
    AE1
    面试
    TS 基础数据类型
    vue-cli结构介绍
    js异步加载的5种方式
    slot 插槽的使用
    使用组件的细节点
    Vue 条件渲染
  • 原文地址:https://www.cnblogs.com/zl0372/p/php_jiweidu.html
Copyright © 2020-2023  润新知