Microseer.getLocation(object)

获取用户当前经纬度和逆地理编码,如果需要获取逆地理编码,reGeocode,请设置为true。

注意

  • reGeoCode 为true时,需要联网请求,会有几秒的延时;

  • 如果不设置reGeoCode,只会返回 longitude 和 latitude

object 参数说明

参数名 类型 必填 说明
reGeocode bool 否 是否获取逆地理编码(地址信息),默认为否
locationOutTime int 否 定位超时时间,最小值为2 默认为10
regoecodeOutTime int 否 逆地理编码超时时间,最小值为2 默认为5
precision int 否 定位精度,0.最佳精度 1.中等精度 2.最低精度 默认为0
success function 是 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

sucess 回调参数说明

属性 类型 说明
longitude double 经度
latitude double 纬度
formattedAddress string 格式化地址
country string 国家
province string 省/直辖市
city string 市
district string 区
street string 街道名称
number string 门牌号

eg:

var object = {
    reGeocode: true,
    locationOutTime: 5,
    regoecodeOutTime: 3,
    precision: 0,
    success: function(res) {
        alert("latitude:  " + res.latitude + "  longitude:" + res.longitude + "  formattedAddress:" + res.formattedAddress);
        console.log(res.latitude);
        console.log(res.longitude);
        console.log(res.formattedAddress);
        console.log(res.country);
        console.log(res.province);
        console.log(res.city);
        console.log(res.street);
        console.log(res.number);
    },
    fail: function(res) {
        console.error(res);
    },
    complete: function() {
        console.log("complete");
    }
}

Microseer.getLocation(object);

results matching ""

    No results matching ""