ymx-amap-location
    正在准备搜索索引...

    接口 LocationOption

    定位选项

    interface LocationOption {
        beidouFirst?: boolean;
        cacheEnable?: boolean;
        cacheTimeout?: number;
        gpsFirst?: boolean;
        gpsFirstTimeout?: number;
        locationMode?: LocationMode;
        mockEnable?: boolean;
        notAddress?: boolean;
        postToUrl?: string;
        sensorEnable?: boolean;
        timeout?: number;
        watch?: boolean;
        watchInterval?: number;
        wifiScan?: boolean;
    }
    索引

    属性

    beidouFirst?: boolean

    是否优先使用北斗

    false
    
    cacheEnable?: boolean

    缓存策略

    false
    
    cacheTimeout?: number

    缓存超时时间

    0
    
    gpsFirst?: boolean

    是否优先使用GPS

    false
    
    gpsFirstTimeout?: number

    GPS优先时的超时时间(秒)

    0
    
    locationMode?: LocationMode

    定位模式

    • 1: 高精度定位模式:同时使用网络定位和GPS定位,优先返回精度高的定位
    • 2: 仅设备定位模式:只使用GPS定位
    • 3: 低功耗定位模式:只使用网络定位
    1
    
    mockEnable?: boolean

    是否允许模拟位置

    true
    
    notAddress?: boolean

    不需要地址信息

    false
    

    不需要地址信息时的定位速度更快,消耗更少的流量

    postToUrl?: string

    将定位数据 POST (Content-Type: application/json) 发送到服务器地址

    APP 被推到后台以后 HTML js 页面会暂停运行,页面将无法处理定位数据; 如需后台获取位置信息,请提供一个链接地址,由APP发起原生请求将定位结果 POST 给你的服务器; 暂不支持传递额外数据,如需鉴权,请将鉴权参数放在 URL 链接上

    sensorEnable?: boolean

    是否使用传感器

    true
    
    timeout?: number

    定位超时时间(秒)

    30
    

    建议设置为 2 - 30 之间,精度要求越高则耗时越长,如果超时仍未取得需要的定位精度将返回已取得的最高精度

    watch?: boolean

    连续定位,注意连续定位过程中最好设备移动位置,如果位置没有变化,可能不会有回调

    false
    

    调用 stop() 停止定位

    watchInterval?: number

    连续定位时间间隔(秒)

    1
    

    最低 1 秒

    wifiScan?: boolean

    是否刷新 WIFI

    true