0.0.8 • Published 6 years ago
geo-for-http v0.0.8
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 | StringStringString | '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 | StringObject | '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 | FloatFloatString | (current postion latitude)(current postion longitude)(the map you're using) | Callback function of the getCurrentPosition() . |