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 🙏

© 2025 – Pkg Stats / Ryan Hefner

crush-location

v1.0.7

Published

个人测试定位插件

Readme

定位功能测试插件

集合了高德地图和腾讯地图的精准定位(浏览器定位)、IP定位、地址解析、逆地址解析相关方法。

仅供个人测试使用,切勿应用于真实项目。

1. 规范

本插件采用CommonJS规范。

2. 使用

(1) 初始化 init(brand, options)

| 参数 | 类型 | 是否必传 | 说明 | | :-------------- | ------ | -------- | ------------------------------------------------------------ | | brand | String | true | 该参数只可传两个值:geo或qq,以区别使用高德地图还是腾讯地图 | | options | Object | true | 相关配置项 | | options.key | String | true | 该参数为申请高德/腾讯地图API时的key值 | | options.sk | String | false | 高德地图API安全密钥,自2021年12月02日高德地图升级之后所申请的 key 必须配备安全密钥一起使用 | | options.referer | String | false | 腾讯地图API应用名称,若选择使用腾讯地图API,该值必传 |

该方法返回一个Promiseresolve一个对象,该对象中共4个方法:

  • getLocation

  • getIpLocation

  • getAddress

  • getPosition

(2) 精准定位(浏览器定位) getLocation(type)

| 参数 | 类型 | 是否必传 | 说明 | | ---- | ------ | -------- | ------------------------------------------------------------ | | type | String | 是 | 该参数只可传两个值:jsapi或webapijsapi:使用组件的方式获取定位webapi:使用web服务(http请求)的方式获取定位 |

该方法返回一个Promise

(3) IP定位 getIpLocation(type)

参数和返回同精准定位

(4) 逆地址解析 getAddress(type, lng, lat)

| 参数 | 类型 | 是否必传 | 说明 | | ---- | ------ | -------- | ------------------------------------------------------------ | | type | String | 是 | 该参数只可传两个值:jsapi或webapijsapi:使用组件的方式获取定位webapi:使用web服务(http请求)的方式进行解析 | | lng | Number | 是 | 经度 | | lat | Number | 是 | 纬度 |

该方法返回一个Promise

(5) 地址解析 getPosition(type, address)

| 参数 | 类型 | 是否必传 | 说明 | | ------- | ------ | -------- | ------------------------------------------------------------ | | type | String | 是 | 该参数只可传两个值:jsapi或webapijsapi:使用组件的方式获取定位webapi:使用web服务(http请求)的方式进行解析 | | address | String | 是 | 地址描述,如浙江省滨江区长河街道 |

该方法返回一个Promise

3. 注意事项

使用腾讯地图API通过http请求的方式获取定位或解析,存在跨域问题,本地调试需进行代理,webpack配置如下:

proxy: {
    '/location': {
        target: 'https://apis.map.qq.com',
        changeOrigin: true,
        pathRewrite: { '^/location': '' },
    },
},