正则表达式-经纬度是否合法

        //检查经度是否合法
        function checkLon(lon) {
            var reg = /^-?((0|1?[0-8]?[0-9]?)(([.][0-9]{1,10})?)|180(([.][0]{1,10})?))$/;
            return reg.test(lon);
        };
        //检查纬度是否合法
        function checkLat(lat) {
            var reg = /^-?((0|[1-8]?[0-9]?)(([.][0-9]{1,10})?)|90(([.][0]{1,10})?))$/;
            return reg.test(lat);
        };

中国国内的经纬度范围:

经度:72.004 < x < 137.8347

纬度:0.8293 < y < 55.8271

原文地址:https://www.cnblogs.com/jeff151013/p/11171995.html