欢迎来到天天文库
浏览记录
ID:53070787
大小:15.76 KB
页数:2页
时间:2020-04-01
《谷歌地图坐标纠偏算法javascript版.docx》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/***gps纠偏算法,适用于google,高德体系的地图*/varpi=3.14159265358979324;varaa=6378245.0;varee=0.00669342162296594323;varGpsCorrect={transform:function(wgLat,wgLon){varlatlng=[];if(GpsCorrect.outOfChina(wgLat,wgLon)){latlng[0]=parseFloat(wgLat);latlng[1]=parseFloat(wgLon);}else{vardLat=GpsCorr
2、ect.transformLat(wgLon-105.0,wgLat-35.0);vardLon=GpsCorrect.transformLon(wgLon-105.0,wgLat-35.0);varradLat=wgLat/180.0*pi;varmagic=Math.sin(radLat);magic=1-ee*magic*magic;varsqrtMagic=Math.sqrt(magic);dLat=(dLat*180.0)/((aa*(1-ee))/(magic*sqrtMagic)*pi);dLon=(dLon*180.0)/(aa/sq
3、rtMagic*Math.cos(radLat)*pi);latlng[0]=parseFloat(wgLat)+dLat;latlng[1]=parseFloat(wgLon)+dLon;}returnlatlng;},outOfChina:function(lat,lon){if(lon<72.004
4、
5、lon>137.8347)returntrue;if(lat<0.8293
6、
7、lat>55.8271)returntrue;returnfalse;},transformLat:function(x,y){varret=-100.0+2.0*x+
8、3.0*y+0.2*y*y+0.1*x*y+0.2*Math.sqrt(Math.abs(x));ret+=(20.0*Math.sin(6.0*x*pi)+20.0*Math.sin(2.0*x*pi))*2.0/3.0;ret+=(20.0*Math.sin(y*pi)+40.0*Math.sin(y/3.0*pi))*2.0/3.0;ret+=(160.0*Math.sin(y/12.0*pi)+320*Math.sin(y*pi/30.0))*2.0/3.0;returnret;},transformLon:function(x,y){var
9、ret=300.0+x+2.0*y+0.1*x*x+0.1*x*y+0.1*Math.sqrt(Math.abs(x));ret+=(20.0*Math.sin(6.0*x*pi)+20.0*Math.sin(2.0*x*pi))*2.0/3.0;ret+=(20.0*Math.sin(x*pi)+40.0*Math.sin(x/3.0*pi))*2.0/3.0;ret+=(150.0*Math.sin(x/12.0*pi)+300.0*Math.sin(x/30.0*pi))*2.0/3.0;returnret;}}调用:varpointCorre
10、ct=GpsCorrect.transform(mapY,mapX);lo=pointCorrect[1];la=pointCorrect[0];
此文档下载收益归作者所有