hiwanz / Wgs2mars.js
地球坐标系 (WGS-84)转火星坐标系 (GCJ-02)地图纠偏算法Javascript版
Stars: ✭ 297
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
Projects that are alternatives of or similar to Wgs2mars.js
Leaflet-active-area
A Leaflet plugin to center the map not in the center of the map but inside a DIV. Useful for responsive design.
Stars: ✭ 99 (-66.67%)
Mutual labels: map
Kind Of
Get the native JavaScript type of a value, fast. Used by superstruct, micromatch and many others!
Stars: ✭ 268 (-9.76%)
Mutual labels: map
map-machine
Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
Stars: ✭ 82 (-72.39%)
Mutual labels: map
django-leaflet-admin-list
The Django Leaflet Admin List package provides an admin list view featured by the map and bounding box filter for the geo-based data of the GeoDjango.
Stars: ✭ 28 (-90.57%)
Mutual labels: map
Election Geodata
Precinct shapes (and vote results) for US elections past, present, and future
Stars: ✭ 289 (-2.69%)
Mutual labels: map
js-collections-map-set
Repository to have example code to demonstrate JavaScript Map and Set data structures.
Stars: ✭ 21 (-92.93%)
Mutual labels: map
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+5951.18%)
Mutual labels: map
Covid19
an interactive, animated COVID-19 coronavirus map to track the outbreak over time by country and by region for selected countries
Stars: ✭ 295 (-0.67%)
Mutual labels: map
TileMapGenerator
Create your own 2D Maps with layer-by-layer system using Noise-Sample and BufferedImage pattern
Stars: ✭ 19 (-93.6%)
Mutual labels: map
Arcgis Runtime Samples Ios
Swift samples demonstrating various capabilities of ArcGIS Runtime SDK for iOS
Stars: ✭ 275 (-7.41%)
Mutual labels: map
Gonorth
GoNorth is a story and content planning tool for RPGs and other open world games.
Stars: ✭ 289 (-2.69%)
Mutual labels: map
地球坐标系 (WGS-84)到火星坐标系 (GCJ-02) Javascript版
前言
此版本相对之前的release做了部分重构,主要调整的内容有:
1. 优化边界判断算法,使用网上公开的中国边界坐标数据作为地图的不规则图形描边,并判断当前坐标是否落在多边形区域内
2. 使用webpack4作为打包工具
3. 使用eslint审查代码
查看示例
若已经安装了nodejs,可以在命令行下切换到项目目录执行
npm start
浏览器会自动打开http://localhost:1024/,允许浏览器定位,查看纠偏效果。
若出现端口冲突,请修改webpack.config.js文件。 若未安装nodejs,可以直接到demo目录下用浏览器打开index.html文件,查看默认设置的坐标纠偏效果。
通过script引入
引入脚本
<script src="lib/wgs2mars.min.js"></script>
调用代码(参数分别为经度和纬度);
var gcjloc = transformFromWGSToGCJ(119.3122312,26.0240049);
返回GCJ-02坐标对象
{lng: 119.31705425869873, lat: 26.02096344048847}
作为node模块引入
可通过npm install下载作为node模块引入
npm install wgs2mars --save-dev
然后在项目中引入
var transform = require('wgs2mars');
var gcjloc = transform(119.3122312,26.0240049);// 返回{lng: 119.31705425869873, lat: 26.02096344048847}
致谢
感谢其他语言版本开源作者的贡献!
地图官方坐标系转换:
目前各个地图服务提供商都开放了转换服务,推荐使用官方的API
该版本算法参考了以下几个项目的相关实现:
C#版:地球坐标系 (WGS-84) 到火星坐标系 (GCJ-02) 的转换算法
C语言版:ChinaMapShift
点在多边形内算法:PNPOLY - Point Inclusion in Polygon Test
中国区域判断为粗略计算,边界数据中会排除台湾,香港什么的你懂的。如下图:
免责声明
该Javascript版本算法是基于网络上公开已知的其他语言算法实现的移植版本,作者不对其准确性和合法性做保证。
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].