All Projects → hujiulong → Gcoord

hujiulong / Gcoord

Licence: mit
地理坐标系转换工具

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gcoord

L7
🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis framework which relies on Mapbox GL or AMap to render basemaps.
Stars: ✭ 2,517 (+14.1%)
Mutual labels:  geojson, map
amap
行政区域查询,根据经纬度快速地查找特定的行政区域信息、省市区信息、中国省市区数据。Administrative region query: to quickly find specific administrative region information based on latitude and longitude provincial information urban China data
Stars: ✭ 31 (-98.59%)
Mutual labels:  map, geojson
geofiddle
Geometric conversions between different formats and projections
Stars: ✭ 15 (-99.32%)
Mutual labels:  geojson, wgs84
Mapboxstatic.swift
Static map snapshots with overlays in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 162 (-92.66%)
Mutual labels:  geojson, map
Mapbox Gl Js
Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
Stars: ✭ 8,017 (+263.42%)
Mutual labels:  geojson, map
vaguely-rude-places
The map of Vaguely Rude Place Names
Stars: ✭ 19 (-99.14%)
Mutual labels:  map, geojson
node-isochrone
NodeJS isochrone map library
Stars: ✭ 27 (-98.78%)
Mutual labels:  map, geojson
Geolib
Zero dependency library to provide some basic geo functions
Stars: ✭ 3,675 (+66.59%)
Mutual labels:  geojson, wgs84
Vector Datasource
Tilezen vector tile service - OpenStreetMap data in several formats
Stars: ✭ 427 (-80.64%)
Mutual labels:  geojson, map
Mapbox Gl Native
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
Stars: ✭ 4,091 (+85.45%)
Mutual labels:  geojson, map
Geojson2svg
Converts geojson to svg string given svg viewport size and maps extent.
Stars: ✭ 117 (-94.7%)
Mutual labels:  geojson, map
China geojson
中国行政区划地图数据(省、市、县),geojson格式,可直接用于D3.js,Echarts.js可视化
Stars: ✭ 51 (-97.69%)
Mutual labels:  geojson, map
Mapbox Gl Native Android
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
Stars: ✭ 135 (-93.88%)
Mutual labels:  geojson, map
Geojsonify
Easily add GeoJson layers to your Maps
Stars: ✭ 141 (-93.61%)
Mutual labels:  geojson
Cachego
Golang Cache component - Multiple drivers
Stars: ✭ 148 (-93.29%)
Mutual labels:  map
Country Iso
🗺 Get the ISO 3166-1 alpha-3 country code from geographic coordinates.
Stars: ✭ 141 (-93.61%)
Mutual labels:  geojson
React Network Diagrams
Contains ESnet network mapping and circuit rendering code, as used in the ESnet portal.
Stars: ✭ 138 (-93.74%)
Mutual labels:  map
Openrailwaymap
An OpenStreetMap-based project for creating a map of the world's railway infrastructure.
Stars: ✭ 150 (-93.2%)
Mutual labels:  map
Vts Browser Js
JavaScript WebGL 3D map rendering engine
Stars: ✭ 148 (-93.29%)
Mutual labels:  map
Openlayers Editor
OpenLayers Editor
Stars: ✭ 138 (-93.74%)
Mutual labels:  map

Gcoord

npm version codecov gzip size LICENSE 996.icu

gcoord(geographic coordinates)是一个处理地理坐标系的JS库,用来修正百度地图、高德地图及其它互联网地图坐标系不统一的问题。

支持转换坐标数组和GeoJSON数据,能在node环境以及所有现代浏览器(IE8+)中运行,gzip后仅3kb。

更多信息可以阅读地理坐标系

🚨 注意

在发布、展示、传播数据时,请务必遵守相关法律规定

(禁止)未经批准,在测绘活动中擅自采用国际坐标系统
— 中华人民共和国测绘法,40 (1)

导航电子地图在公开出版、销售、传播、展示和使用前,必须进行空间位置技术处理。
— GB 20263―2006《导航电子地图安全处理技术基本要求》,4.1

Install

通过npm安装:

npm install gcoord --save

或者直接在页面中引入:

<script src="https://unpkg.com/gcoord/dist/gcoord.js"></script>

Import

CommonJS:

const gcoord = require('gcoord');

ES Module:

import gcoord from 'gcoord';

同时也支持AMD和CMD规范

Usage

例如从手机的GPS得到一个经纬度坐标,需要将其展示在百度地图上,则应该将当前坐标从WGS-84坐标系转换为BD-09坐标系

var result = gcoord.transform(
  [116.403988, 39.914266],    // 经纬度坐标
  gcoord.WGS84,               // 当前坐标系
  gcoord.BD09                 // 目标坐标系
);

console.log(result);  // [116.41661560068297, 39.92196580126834]

同时gcoord还可以转换GeoJSON对象的坐标系,详细使用方式可以参考API

API

transform(input, from, to)

进行坐标转换

参数

返回值

GeoJSON | Array<number>

示例

// 将GCJ02坐标转换为WGS84坐标
var result = gcoord.transform([123, 45], gcoord.GCJ02, gcoord.WGS84);
console.log(result);  // [122.99395597, 44.99804071]
// 转换GeoJSON坐标
var geojson = {
  "type": "Point",
  "coordinates": [123, 45]
}
gcoord.transform(geojson, gcoord.GCJ02, gcoord.WGS84);
console.log(geojson.coordinates); // [122.99395597, 44.99804071]

返回数组或GeoJSON对象(由输入决定),注意:当输入为GeoJSON时,transform会改变输入对象

CRS

CRS为坐标系,目标支持以下几种坐标系

CRS             坐标格式 说明  
gcoord.WGS84 [lng,lat] WGS-84坐标系,GPS设备获取的经纬度坐标
gcoord.GCJ02 [lng,lat] GCJ-02坐标系,google中国地图、soso地图、aliyun地图、mapabc地图和高德地图所用的经纬度坐标
gcoord.BD09 [lng,lat] BD-09坐标系,百度地图采用的经纬度坐标
gcoord.BD09LL [lng,lat] 同BD09
gcoord.BD09MC [x,y] BD-09米制坐标,百度地图采用的米制坐标,单位:米
gcoord.BD09Meter [x,y] 同BD09MC
gcoord.Baidu [lng,lat] 百度坐标系,BD-09坐标系别名,同BD-09
gcoord.BMap [lng,lat] 百度地图,BD-09坐标系别名,同BD-09
gcoord.AMap [lng,lat] 高德地图,同GCJ-02
gcoord.WebMercator [x,y] Web Mercator投影,墨卡托投影,同EPSG3857,单位:米
gcoord.WGS1984 [lng,lat] WGS-84坐标系别名,同WGS-84
gcoord.EPSG4326 [lng,lat] WGS-84坐标系别名,同WGS-84
gcoord.EPSG3857 [x,y] Web Mercator投影,同WebMercator,单位:米
gcoord.EPSG900913 [x,y] Web Mercator投影,同WebMercator,单位:米

支持更多坐标系? gcoord的目标是处理web地图中的坐标,目前支持的坐标系已经能满足绝大部分要求了,同时gcoord也能保持轻量。如果需要更专业的坐标系处理工具,可以使用proj4js等开源库

LICENSE

MIT

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].