npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ne_fe/gis

v1.2.2

Published

gis util for NxE

Downloads

40

Readme

ne-gis

ne 前端地图组件 - 高性能经纬度转换库

简介

经纬度转换

安装&配置

$ npm i @ne_fe/gis -D
// webpack.config.js
const path = require('path');
const WasmModuleWebpackPlugin = require('wasm-module-webpack-plugin');

...
{
  test: /\.m?js$/,
  exclude: /(node_modules|bower_components)/,
  include: [ path.join(process.cwd(), './node_modules/@ne_fe/gis') ],
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env'],
      plugins: [ '@babel/plugin-syntax-dynamic-import', WasmModuleWebpackPlugin.BabelPlugin ]
    }
  }
}

...

plugins: [
  new WasmModuleWebpackPlugin.WebpackPlugin()
]

...

坐标转换-GPS转当前地图坐标

Note: 由于使用webssembly实现,所以 longitude、latitude 暂时只支持number类型

import neGis from '@ne_fe/gis';
const gps = [];
let lngX = 116.3;
let latY = 39.9;
gps.push({ longitude: lngX, latitude: latY });
for (let i = 1; i < 40; i++) {
    lngX = lngX + Math.random() * 0.0005;
    if (i % 2) {
        latY = latY + Math.random() * 0.0001;
    } else {
        latY = latY + Math.random() * 0.0006;
    }
    gps.push({ longitude: lngX, latitude: latY });
}
// 转腾讯地图 确保已经加载腾讯地图sdk 不仅会对数值做计算转换,还会转为腾讯地图经纬度对象
neGis.translateFromGPS(gps, 't', 1).then(res => {
  console.log(res);
});
// 转腾讯地图 只会对数值做计算转换 可以不用加载腾讯地图sdk 
neGis.translateFromGPS(gps, 't', 0).then(res => {
  console.log(res);
});
neGis.translateFromGPS(gps, 't').then(res => {
  console.log(res);
});
// 还可对每条转换后数据进行操作
// 第三个参数必须,不能省略,第四个参数为一个函数,两个参数分别为该条数据的值与下标,返回新数据
neGis.translateFromGPS(gps, 't', 0, (value, index) => {
  console.log(value, index);
  return value;
}).then(res => {
  console.log(res);
});

// 注意 1.1.0以上版本会保留原始数据,示例如下

const gpsTest = [
  {
    longitude: 116.3,
    latitude: 39.9,
    tkey: 111,
  }
];
neGis.translateFromGPS(gpsTest, 't', 1).then(res => {
  console.log(res);
  // [{ lng: 116.29787221, lat: 39.921133, longitude: 116.3, latitude: 39.9, tkey: 111 }]
});

坐标转换-当前地图坐标转GPS

Note: 由于使用webssembly实现,所以 lat、lng 暂时只支持number类型

import neGis from '@ne_fe/gis';
const gps = [];
let lngX = 116.3;
let latY = 39.9;
gps.push(new qq.maps.latlng(latY, lngX));
for (let i = 1; i < 40; i++) {
    lngX = lngX + Math.random() * 0.0005;
    if (i % 2) {
        latY = latY + Math.random() * 0.0001;
    } else {
        latY = latY + Math.random() * 0.0006;
    }
    gps.push(new qq.maps.latlng(latY, lngX));
}
// 转GPS使用的坐标系
neGis.translateToGPS(gps, 't').then(res => {
  console.log(res);
});

// 注意 1.1.0以上版本会保留原始数据,示例如下

const gpsTest = [
  {
    ...new qq.maps.latlng(39.921133, 116.29787221),
    tkey: 111,
  }
];
neGis.translateToGPS(gpsTest, 't').then(res => {
  console.log(res);
  // [{ lng: 116.29787221, lat: 39.921133, longitude: 116.3, latitude: 39.9, tkey: 111 }]
});