a small tool to getCurrentPosition in http protocol
npm install geo-for-http
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 | 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() . |