gdmap-utils 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.html +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 地图工具库
|
|
3
|
+
*/
|
|
4
|
+
export declare class MapUtils {
|
|
5
|
+
/**
|
|
6
|
+
* 计算两个经纬度之间的距离
|
|
7
|
+
* @param lat1 第一个点的纬度
|
|
8
|
+
* @param lon1 第一个点的经度
|
|
9
|
+
* @param lat2 第二个点的纬度
|
|
10
|
+
* @param lon2 第二个点的经度
|
|
11
|
+
* @returns 距离(单位:米)
|
|
12
|
+
*/
|
|
13
|
+
static calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* 将经纬度转换为墨卡托坐标
|
|
16
|
+
* @param lat 纬度
|
|
17
|
+
* @param lon 经度
|
|
18
|
+
* @returns 墨卡托坐标 [x, y]
|
|
19
|
+
*/
|
|
20
|
+
static latLngToMercator(lat: number, lon: number): [number, number];
|
|
21
|
+
/**
|
|
22
|
+
* 将墨卡托坐标转换为经纬度
|
|
23
|
+
* @param x 墨卡托坐标 x
|
|
24
|
+
* @param y 墨卡托坐标 y
|
|
25
|
+
* @returns 经纬度 [lat, lon]
|
|
26
|
+
*/
|
|
27
|
+
static mercatorToLatLng(x: number, y: number): [number, number];
|
|
28
|
+
}
|
|
29
|
+
export default MapUtils;
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,QAAQ;IACnB;;;;;;;OAOG;IACH,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAexF;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAOnE;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAMhE;AAGD,eAAe,QAAQ,CAAC"}
|
package/dist/index.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Map Utils Demo</title><script defer="defer" src="index.js"></script></head><body><h1>地图工具库演示</h1><div id="app"><p>使用 F12 打开控制台,查看 MapUtils 的使用示例。</p></div></body></html>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("MapUtils",[],e):"object"==typeof exports?exports.MapUtils=e():t.MapUtils=e()}(this,()=>(()=>{"use strict";var t={d:(e,a)=>{for(var o in a)t.o(a,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:a[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{MapUtils:()=>a,default:()=>o});var a=function(){function t(){}return t.calculateDistance=function(t,e,a,o){var n=t*Math.PI/180,r=a*Math.PI/180,M=(a-t)*Math.PI/180,i=(o-e)*Math.PI/180,c=Math.sin(M/2)*Math.sin(M/2)+Math.cos(n)*Math.cos(r)*Math.sin(i/2)*Math.sin(i/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},t.latLngToMercator=function(t,e){var a=20037508.34*e/180,o=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return[a,o=20037508.34*o/180]},t.mercatorToLatLng=function(t,e){var a=t/20037508.34*180,o=e/20037508.34*180;return[o=180/Math.PI*(2*Math.atan(Math.exp(o*Math.PI/180))-Math.PI/2),a]},t}();console.log("你好世界哈哈哈");const o=a;return e})());
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,WAAY,GAAIH,GACG,iBAAZC,QACdA,QAAkB,SAAID,IAEtBD,EAAe,SAAIC,GACpB,CATD,CASGK,KAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,M,kDCDvD,8BAiDA,QAxCS,EAAAC,kBAAP,SAAyBC,EAAcC,EAAcC,EAAcC,GACjE,IACM,EAAKH,EAAOI,KAAKC,GAAK,IACtB,EAAKH,EAAOE,KAAKC,GAAK,IACtB,GAAMH,EAAOF,GAAQI,KAAKC,GAAK,IAC/B,GAAMF,EAAOF,GAAQG,KAAKC,GAAK,IAE/BC,EAAIF,KAAKG,IAAI,EAAK,GAAKH,KAAKG,IAAI,EAAK,GACjCH,KAAKI,IAAI,GAAMJ,KAAKI,IAAI,GACxBJ,KAAKG,IAAI,EAAK,GAAKH,KAAKG,IAAI,EAAK,GAG3C,OAFU,EAAIH,KAAKK,MAAML,KAAKM,KAAKJ,GAAIF,KAAKM,KAAK,EAAIJ,IAT3C,MAYZ,EAQO,EAAAK,iBAAP,SAAwBC,EAAaC,GACnC,IAAMC,EAAU,YAAND,EAAoB,IAC1BE,EAAIX,KAAKY,IAAIZ,KAAKa,KAAK,GAAKL,GAAOR,KAAKC,GAAK,OAASD,KAAKC,GAAK,KAEpE,MAAO,CAACS,EADRC,EAAQ,YAAJA,EAAkB,IAExB,EAQO,EAAAG,iBAAP,SAAwBJ,EAAWC,GACjC,IAAMF,EAAMC,EAAI,YAAc,IAC1BF,EAAMG,EAAI,YAAc,IAE5B,MAAO,CADPH,EAAM,IAAMR,KAAKC,IAAM,EAAID,KAAKe,KAAKf,KAAKgB,IAAIR,EAAMR,KAAKC,GAAK,MAAQD,KAAKC,GAAK,GACnEQ,EACf,EACF,EAjDA,GAkDAQ,QAAQL,IAAI,WAEZ,U","sources":["webpack://MapUtils/webpack/universalModuleDefinition","webpack://MapUtils/webpack/bootstrap","webpack://MapUtils/webpack/runtime/define property getters","webpack://MapUtils/webpack/runtime/hasOwnProperty shorthand","webpack://MapUtils/webpack/runtime/make namespace object","webpack://MapUtils/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"MapUtils\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"MapUtils\"] = factory();\n\telse\n\t\troot[\"MapUtils\"] = factory();\n})(this, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\r\n * 地图工具库\r\n */\r\n\r\nexport class MapUtils {\r\n /**\r\n * 计算两个经纬度之间的距离\r\n * @param lat1 第一个点的纬度\r\n * @param lon1 第一个点的经度\r\n * @param lat2 第二个点的纬度\r\n * @param lon2 第二个点的经度\r\n * @returns 距离(单位:米)\r\n */\r\n static calculateDistance(lat1: number, lon1: number, lat2: number, lon2: number): number {\r\n const R = 6371e3; // 地球半径(单位:米)\r\n const φ1 = lat1 * Math.PI / 180;\r\n const φ2 = lat2 * Math.PI / 180;\r\n const Δφ = (lat2 - lat1) * Math.PI / 180;\r\n const Δλ = (lon2 - lon1) * Math.PI / 180;\r\n\r\n const a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +\r\n Math.cos(φ1) * Math.cos(φ2) *\r\n Math.sin(Δλ / 2) * Math.sin(Δλ / 2);\r\n const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\r\n\r\n return R * c;\r\n }\r\n\r\n /**\r\n * 将经纬度转换为墨卡托坐标\r\n * @param lat 纬度\r\n * @param lon 经度\r\n * @returns 墨卡托坐标 [x, y]\r\n */\r\n static latLngToMercator(lat: number, lon: number): [number, number] {\r\n const x = lon * 20037508.34 / 180;\r\n let y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);\r\n y = y * 20037508.34 / 180;\r\n return [x, y];\r\n }\r\n\r\n /**\r\n * 将墨卡托坐标转换为经纬度\r\n * @param x 墨卡托坐标 x\r\n * @param y 墨卡托坐标 y\r\n * @returns 经纬度 [lat, lon]\r\n */\r\n static mercatorToLatLng(x: number, y: number): [number, number] {\r\n const lon = x / 20037508.34 * 180;\r\n let lat = y / 20037508.34 * 180;\r\n lat = 180 / Math.PI * (2 * Math.atan(Math.exp(lat * Math.PI / 180)) - Math.PI / 2);\r\n return [lat, lon];\r\n }\r\n}\r\nconsole.log(\"你好世界哈哈哈\");\r\n\r\nexport default MapUtils;"],"names":["root","factory","exports","module","define","amd","this","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","calculateDistance","lat1","lon1","lat2","lon2","Math","PI","a","sin","cos","atan2","sqrt","latLngToMercator","lat","lon","x","y","log","tan","mercatorToLatLng","atan","exp","console"],"ignoreList":[],"sourceRoot":""}
|