Files
jiapu/dist/public/js/lay-module/location/locationX.js
T

2 lines
2.6 KiB
JavaScript

layui.define(["layer"],function(f){var I=layui.jquery,_=layui.layer,d="locationX",M={PI:3.141592653589793,x_pi:3.141592653589793*3e3/180,delta:function(t,a){var r=6378245,n=.006693421622965943,i=this.transformLat(a-105,t-35),h=this.transformLon(a-105,t-35),e=t/180*this.PI,s=Math.sin(e);s=1-n*s*s;var o=Math.sqrt(s);return i=i*180/(r*(1-n)/(s*o)*this.PI),h=h*180/(r/o*Math.cos(e)*this.PI),{lat:i,lon:h}},gcj_encrypt:function(t,a){if(this.outOfChina(t,a))return{lat:t,lon:a};var r=this.delta(t,a);return{lat:t+r.lat,lon:a+r.lon}},gcj_decrypt:function(t,a){if(this.outOfChina(t,a))return{lat:t,lon:a};var r=this.delta(t,a);return{lat:t-r.lat,lon:a-r.lon}},gcj_decrypt_exact:function(t,a){for(var r=.01,n=1e-9,i=r,h=r,e=t-i,s=a-h,o=t+i,l=a+h,c,u,P=0;;){c=(e+o)/2,u=(s+l)/2;var v=this.gcj_encrypt(c,u);if(i=v.lat-t,h=v.lon-a,Math.abs(i)<n&&Math.abs(h)<n||(i>0?o=c:e=c,h>0?l=u:s=u,++P>1e4))break}return{lat:c,lon:u}},bd_encrypt:function(t,a){var r=a,n=t,i=Math.sqrt(r*r+n*n)+2e-5*Math.sin(n*this.x_pi),h=Math.atan2(n,r)+3e-6*Math.cos(r*this.x_pi);return bdLon=i*Math.cos(h)+.0065,bdLat=i*Math.sin(h)+.006,{lat:bdLat,lon:bdLon}},bd_decrypt:function(t,a){var r=a-.0065,n=t-.006,i=Math.sqrt(r*r+n*n)-2e-5*Math.sin(n*this.x_pi),h=Math.atan2(n,r)-3e-6*Math.cos(r*this.x_pi),e=i*Math.cos(h),s=i*Math.sin(h);return{lat:s,lon:e}},bd_WGS84:function(t,a){var r=M.bd_decrypt(t,a);return M.gcj_decrypt(r.lat,r.lon)},WGS84_bd:function(t,a){var r=M.gcj_encrypt(t,a);return M.bd_encrypt(r.lat,r.lon)},mercator_encrypt:function(t,a){var r=a*2003750834e-2/180,n=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return n=n*2003750834e-2/180,{lat:n,lon:r}},mercator_decrypt:function(t,a){var r=a/2003750834e-2*180,n=t/2003750834e-2*180;return n=180/this.PI*(2*Math.atan(Math.exp(n*this.PI/180))-this.PI/2),{lat:n,lon:r}},distance:function(t,a,r,n){var i=6371e3,h=Math.cos(t*this.PI/180)*Math.cos(r*this.PI/180)*Math.cos((a-n)*this.PI/180),e=Math.sin(t*this.PI/180)*Math.sin(r*this.PI/180),s=h+e;s>1&&(s=1),s<-1&&(s=-1);var o=Math.acos(s),l=o*i;return l},outOfChina:function(t,a){return a<72.004||a>137.8347||t<.8293||t>55.8271},transformLat:function(t,a){var r=-100+2*t+3*a+.2*a*a+.1*t*a+.2*Math.sqrt(Math.abs(t));return r+=(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))*2/3,r+=(20*Math.sin(a*this.PI)+40*Math.sin(a/3*this.PI))*2/3,r+=(160*Math.sin(a/12*this.PI)+320*Math.sin(a*this.PI/30))*2/3,r},transformLon:function(t,a){var r=300+t+2*a+.1*t*t+.1*t*a+.1*Math.sqrt(Math.abs(t));return r+=(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))*2/3,r+=(20*Math.sin(t*this.PI)+40*Math.sin(t/3*this.PI))*2/3,r+=(150*Math.sin(t/12*this.PI)+300*Math.sin(t/30*this.PI))*2/3,r}};f(d,M)});