Skip to content

a small tool to getCurrentPosition in http protocol

Notifications You must be signed in to change notification settings

zyf394/geo-for-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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().