推荐的翻墙服务:JustMySocks3或JustMySocks5,支持SS和V2Ray,自带防和谐动态切IP
hiwanz / wgs2mars.js Goto Github PK
View Code? Open in Web Editor NEW地球坐标系 (WGS-84)转火星坐标系 (GCJ-02)地图纠偏算法Javascript版
地球坐标系 (WGS-84)转火星坐标系 (GCJ-02)地图纠偏算法Javascript版
推荐的翻墙服务:JustMySocks3或JustMySocks5,支持SS和V2Ray,自带防和谐动态切IP
outOfChina 函数把东南亚全部吞并了 :)
我改了一下
function Rectangle(lat1, lng1, lat2, lng2) {
this.East = Math.max(lng1, lng2);
this.South = Math.min(lat1, lat2);
this.West = Math.min(lng1, lng2);
this.North = Math.max(lat1, lat2);
}
function IsInRect(rect, lat, lon) {
return rect.West <= lon && rect.East >= lon && rect.North >= lat && rect.South <= lat;
}
var region = [
new Rectangle(49.220400, 79.446200, 42.889900, 96.330000),
new Rectangle(54.141500, 109.687200, 39.374200, 135.000200),
new Rectangle(42.889900, 73.124600, 29.529700, 124.143255),
new Rectangle(29.529700, 82.968400, 26.718600, 97.035200),
new Rectangle(29.529700, 97.025300, 20.414096, 124.367395),
new Rectangle(20.414096, 107.975793, 17.871542, 111.744104)
];
var exclude = [
new Rectangle(25.398623, 119.921265, 21.785006, 122.497559),
new Rectangle(22.284000, 101.865200, 20.098800, 106.665000),
new Rectangle(21.542200, 106.452500, 20.487800, 108.051000),
new Rectangle(55.817500, 109.032300, 50.325700, 119.127000),
new Rectangle(55.817500, 127.456800, 49.557400, 137.022700),
new Rectangle(44.892200, 131.266200, 42.569200, 137.022700)
];
function IsInChina(lat, lon) {
for (var i = 0; i < region.length; i++) {
if (IsInRect(region[i], lat, lon))
{
for (var j = 0; j < exclude.length; j++)
{
if (IsInRect(exclude[j], lat, lon))
{
return false;
}
}
return true;
}
}
return false;
}
添加区域到region和exclude可以让判断更加精确
主要参考了这篇文章: http://www.cnblogs.com/Aimeast/archive/2012/08/09/2629614.html
data at 2015.10.11
NMEA from GPS source:
lat = 39.5768506
lon = 116.2097481
Real Location (From 1. android API 2. picked by BaiduMap):
lat = 39.96165504
lon = 116.35180069
If you have any improvement,
Please contact me @ [email protected]
Thank you very much !
113.93350333333330.004863655301697745, 22.49373-0.0030327378576604272
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.