Skip to content

aipaw/eeui-plugin-geolocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

地理定位

安装

eeui plugin install https://github.com/aipaw/eeui-plugin-geolocation

卸载

eeui plugin uninstall https://github.com/aipaw/eeui-plugin-geolocation

引用

const geolocation = app.requireModule("eeui/geolocation");

get(callback) 获取当前定位

参数

  1. [callback] (Function)

返回

  1. result (Object)
    • latitude (Float)

    • longitude (Float)

    • speed (Float) (m/s)

    • accuracy (Int) (m)

示例

geolocation.get((ret) => {
    console.log(ret)
})

watch(options, callback) 实时监听定位

  1. [options] (Object)

    • maximumAge (Int) (ms)

    • timeout (Int) (ms)

    • model (String) (highAccuracy | lowAccuracy, default: highAccuracy)

  2. [callback] (Function)

返回

  1. result (Object)
    • latitude (Float)

    • longitude (Float)

    • speed (Float) (m/s)

    • accuracy (Int) (m)

示例

geolocation.watch((ret) => {
    console.log(ret)
})

clearWatch(callback) 取消监听定位

参数

  1. [callback] (Function)

示例

geolocation.clearWatch(() => {
    console.log('cleared')
})

Error
LOCATION_INTERNAL_ERROR
LOCATION_NOT_SUPPORTED
LOCATION_PERMISSION_DENIED
LOCATION_SERVICE_BUSY
GET_LOCATION_INVALID_ARGUMENT
WATCH_LOCATION_INVALID_ARGUMENT
LOCATION_UNAVAILABLE
LOCATION_TIMEOUT