geo-for-http

0.0.8 • Public • Published

a small tool to getCurrentPosition in http protocol

install

npm install geo-for-http

usage

import geo from 'geo-for-http'

// first, use geo.register() to register to the map applicaiton you choose.
geo.register({
  type: 'qq',
  app_key: yourkey,
  app_name: yourappname
});

// then, use geo.getCurrentPosition() to get your current postion.
geo.getCurrentPosition('qq')
  .then( pos => {
    console.log(pos)
  })

API

API arguments type value description
register(arg) arg.type
arg.app_key
arg.app_name
String
String
String
'qq'(default)/'baidu'/'ali'/'h5'
(your app key)
(your app name)
Register to the map applicaiton you choose. QQMAP is highly recommended.
getCurrentPosition(mapType, options) mapType
options
String
Object
'qq'(default)/'baidu'/'ali'/'h5'
How to set options: qqmap/bmap/amap
Options of each map's original getCurrentPosition function, depends on which map you choose. You can ignore it at most of the time.
getCurrentPosition(mapType, options)
.then(pos => {})
pos.lat
pos.lng
pos.maptype
Float
Float
String
(current postion latitude)
(current postion longitude)
(the map you're using)
Callback function of the getCurrentPosition().

Package Sidebar

Install

npm i geo-for-http

Weekly Downloads

3

Version

0.0.8

License

MIT

Unpacked Size

43.6 kB

Total Files

15

Last publish

Collaborators

  • zyf394