Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
2f157d82
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2f157d82
编写于
8月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!23160 位置服务 ArkTS规范整改
Merge pull request !23160 from liuxinbing/master
上级
b1f95d17
cc64a26f
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
195 addition
and
144 deletion
+195
-144
zh-cn/application-dev/device/location-guidelines.md
zh-cn/application-dev/device/location-guidelines.md
+19
-16
zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md
...lication-dev/reference/apis/js-apis-geoLocationManager.md
+146
-100
zh-cn/application-dev/reference/apis/js-apis-geolocation.md
zh-cn/application-dev/reference/apis/js-apis-geolocation.md
+30
-28
未找到文件。
zh-cn/application-dev/device/location-guidelines.md
浏览文件 @
2f157d82
...
...
@@ -149,7 +149,7 @@
以导航场景为例,实例化方式如下:
```
ts
let
requestInfo
=
{
'
scenario
'
:
geoLocationManager
.
LocationRequestScenario
.
NAVIGATION
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
requestInfo
:
geoLocationManager
.
LocationRequest
=
{
'
scenario
'
:
geoLocationManager
.
LocationRequestScenario
.
NAVIGATION
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
```
**方式二:**
...
...
@@ -179,14 +179,14 @@
以定位精度优先策略为例,实例化方式如下:
```
ts
let
requestInfo
=
{
'
priority
'
:
geoLocationManager
.
LocationRequestPriority
.
ACCURACY
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
requestInfo
:
geoLocationManager
.
LocationRequest
=
{
'
priority
'
:
geoLocationManager
.
LocationRequestPriority
.
ACCURACY
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
```
4.
实例化Callback对象,用于向系统提供位置上报的途径。
应用需要自行实现系统定义好的回调接口,并将其实例化。系统在定位成功确定设备的实时位置结果时,会通过该接口上报给应用。应用程序可以在接口的实现中完成自己的业务逻辑。
```
ts
let
locationChange
=
(
location
)
=>
{
let
locationChange
=
(
location
:
geoLocationManager
.
Location
):
void
=>
{
console
.
log
(
'
locationChanger: data:
'
+
JSON
.
stringify
(
location
));
};
```
...
...
@@ -209,10 +209,11 @@
```
ts
import
geoLocationManager
from
'
@ohos.geoLocationManager
'
;
import
BusinessError
from
"
@ohos.base
"
;
try
{
let
location
=
geoLocationManager
.
getLastLocation
();
}
catch
(
err
)
{
console
.
error
(
"
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
errCode:
"
+
(
err
as
BusinessError
.
BusinessError
).
code
+
"
,errMessage:
"
+
(
err
as
BusinessError
.
BusinessError
)
.
message
);
}
```
...
...
@@ -259,10 +260,11 @@
```
ts
import
geoLocationManager
from
'
@ohos.geoLocationManager
'
;
import
BusinessError
from
"
@ohos.base
"
;
try
{
let
isAvailable
=
geoLocationManager
.
isGeocoderAvailable
();
}
catch
(
err
)
{
console
.
error
(
"
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
errCode:
"
+
(
err
as
BusinessError
.
BusinessError
).
code
+
"
,errMessage:
"
+
(
err
as
BusinessError
.
BusinessError
)
.
message
);
}
```
...
...
@@ -270,7 +272,7 @@
-
调用getAddressesFromLocation,坐标转化地理位置信息。
```
ts
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest
:
geoLocationManager
.
ReverseGeoCodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
try
{
geoLocationManager
.
getAddressesFromLocation
(
reverseGeocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -280,7 +282,7 @@
}
});
}
catch
(
err
)
{
console
.
error
(
"
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
errCode:
"
+
(
err
as
BusinessError
.
BusinessError
).
code
+
"
,errMessage:
"
+
(
err
as
BusinessError
.
BusinessError
)
.
message
);
}
```
...
...
@@ -288,7 +290,7 @@
-
调用getAddressesFromLocationName位置描述转化坐标。
```
ts
let
geocodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
let
geocodeRequest
:
geoLocationManager
.
GeoCodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
try
{
geoLocationManager
.
getAddressesFromLocationName
(
geocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
...
...
@@ -298,7 +300,7 @@
}
});
}
catch
(
err
)
{
console
.
error
(
"
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
errCode:
"
+
(
err
as
BusinessError
.
BusinessError
).
code
+
"
,errMessage:
"
+
(
err
as
BusinessError
.
BusinessError
)
.
message
);
}
```
...
...
@@ -332,11 +334,12 @@
1.
使用地理围栏功能,需要有权限ohos.permission.APPROXIMATELY_LOCATION,位置权限申请的方法和步骤见
[
申请位置权限开发指导
](
#申请位置权限开发指导
)
。
2.
导入
[
geoLocationManager
](
../reference/apis/js-apis-geoLocationManager.md
)
模块
和
[
wantAgent
](
../reference/apis/js-apis-app-ability-wantAgent
.md
)
模块。
2.
导入
[
geoLocationManager
](
../reference/apis/js-apis-geoLocationManager.md
)
模块
、
[
wantAgent
](
../reference/apis/js-apis-app-ability-wantAgent.md
)
模块和
[
BusinessError
](
../reference/apis/js-apis-base
.md
)
模块。
```
ts
import
geoLocationManager
from
'
@ohos.geoLocationManager
'
;
import
wantAgent
from
'
@ohos.app.ability.wantAgent
'
;
import
BusinessError
from
"
@ohos.base
"
;
```
3.
创建
[
WantAgentInfo
](
../reference/apis/js-apis-inner-wantAgent-wantAgentInfo.md
)
信息。
...
...
@@ -344,10 +347,10 @@
场景一:创建拉起Ability的WantAgentInfo信息。
```
ts
let
wantAgentObj
=
null
;
// 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。
let
wantAgentObj
:
wantAgent
.
WantAgentInfo
|
null
=
null
;
// 用于保存创建成功的wantAgent对象,后续使用其完成触发的动作。
// 通过WantAgentInfo的operationType设置动作类型
let
wantAgentInfo
=
{
let
wantAgentInfo
:
wantAgent
.
WantAgentInfo
=
{
wants
:
[
{
deviceId
:
''
,
...
...
@@ -368,10 +371,10 @@
场景二:创建发布
[
公共事件
](
../application-models/common-event-overview.md
)
的WantAgentInfo信息。
```
ts
let
wantAgentObj
=
null
;
// 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。
let
wantAgentObj
:
wantAgent
.
WantAgentInfo
|
null
=
null
;
// 用于保存创建成功的WantAgent对象,后续使用其完成触发的动作。
// 通过WantAgentInfo的operationType设置动作类型
let
wantAgentInfo
=
{
let
wantAgentInfo
:
wantAgent
.
WantAgentInfo
=
{
wants
:
[
{
action
:
'
event_name
'
,
// 设置事件名
...
...
@@ -397,11 +400,11 @@
}
console
.
info
(
'
getWantAgent success
'
);
wantAgentObj
=
data
;
let
requestInfo
=
{
'
priority
'
:
0x201
,
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
let
requestInfo
:
geoLocationManager
.
GeofenceRequest
=
{
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
try
{
geoLocationManager
.
on
(
'
gnssFenceStatusChange
'
,
requestInfo
,
wantAgentObj
);
}
catch
(
err
)
{
console
.
error
(
"
errCode:
"
+
err
.
code
+
"
,errMessage:
"
+
err
.
message
);
console
.
error
(
"
errCode:
"
+
(
err
as
BusinessError
.
BusinessError
).
code
+
"
,errMessage:
"
+
(
err
as
BusinessError
.
BusinessError
)
.
message
);
}
});
```
...
...
zh-cn/application-dev/reference/apis/js-apis-geoLocationManager.md
浏览文件 @
2f157d82
此差异已折叠。
点击以展开。
zh-cn/application-dev/reference/apis/js-apis-geolocation.md
浏览文件 @
2f157d82
...
...
@@ -68,8 +68,8 @@ on(type: 'locationChange', request: LocationRequest, callback: Callback<Locat
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
location
)
=>
{
let
requestInfo
:
geolocation
.
LocationRequest
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
location
:
geolocation
.
Location
):
void
=>
{
console
.
log
(
'
locationChanger: data:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
locationChange
);
...
...
@@ -101,8 +101,8 @@ off(type: 'locationChange', callback?: Callback<Location>): void
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
location
)
=>
{
let
requestInfo
:
geolocation
.
LocationRequest
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
timeInterval
'
:
0
,
'
distanceInterval
'
:
0
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
location
:
geolocation
.
Location
):
void
=>
{
console
.
log
(
'
locationChanger: data:
'
+
JSON
.
stringify
(
location
));
};
geolocation
.
on
(
'
locationChange
'
,
requestInfo
,
locationChange
);
...
...
@@ -135,7 +135,7 @@ on(type: 'locationServiceState', callback: Callback<boolean>): void
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
locationServiceState
=
(
state
)
=>
{
let
locationServiceState
=
(
state
:
boolean
):
void
=>
{
console
.
log
(
'
locationServiceState:
'
+
JSON
.
stringify
(
state
));
}
geolocation
.
on
(
'
locationServiceState
'
,
locationServiceState
);
...
...
@@ -167,7 +167,7 @@ off(type: 'locationServiceState', callback?: Callback<boolean>): void;
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
locationServiceState
=
(
state
)
=>
{
let
locationServiceState
=
(
state
:
boolean
):
void
=>
{
console
.
log
(
'
locationServiceState: state:
'
+
JSON
.
stringify
(
state
));
}
geolocation
.
on
(
'
locationServiceState
'
,
locationServiceState
);
...
...
@@ -202,10 +202,10 @@ on(type: 'cachedGnssLocationsReporting', request: CachedGnssLocationsRequest, ca
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
cachedLocationsCb
=
(
locations
)
=>
{
let
cachedLocationsCb
=
(
locations
:
Array
<
geolocation
.
Location
>
):
void
=>
{
console
.
log
(
'
cachedGnssLocationsReporting: locations:
'
+
JSON
.
stringify
(
locations
));
}
let
requestInfo
=
{
'
reportingPeriodSec
'
:
10
,
'
wakeUpCacheQueueFull
'
:
true
};
let
requestInfo
:
geolocation
.
CachedGnssLocationsRequest
=
{
'
reportingPeriodSec
'
:
10
,
'
wakeUpCacheQueueFull
'
:
true
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
requestInfo
,
cachedLocationsCb
);
```
...
...
@@ -236,10 +236,10 @@ off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Locati
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
cachedLocationsCb
=
(
locations
)
=>
{
let
cachedLocationsCb
=
(
locations
:
Array
<
geolocation
.
Location
>
):
void
=>
{
console
.
log
(
'
cachedGnssLocationsReporting: locations:
'
+
JSON
.
stringify
(
locations
));
}
let
requestInfo
=
{
'
reportingPeriodSec
'
:
10
,
'
wakeUpCacheQueueFull
'
:
true
};
let
requestInfo
:
geolocation
.
CachedGnssLocationsRequest
=
{
'
reportingPeriodSec
'
:
10
,
'
wakeUpCacheQueueFull
'
:
true
};
geolocation
.
on
(
'
cachedGnssLocationsReporting
'
,
requestInfo
,
cachedLocationsCb
);
geolocation
.
off
(
'
cachedGnssLocationsReporting
'
);
```
...
...
@@ -271,7 +271,7 @@ on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>): voi
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
gnssStatusCb
=
(
satelliteStatusInfo
)
=>
{
let
gnssStatusCb
=
(
satelliteStatusInfo
:
geolocation
.
SatelliteStatusInfo
):
void
=>
{
console
.
log
(
'
gnssStatusChange:
'
+
JSON
.
stringify
(
satelliteStatusInfo
));
}
geolocation
.
on
(
'
gnssStatusChange
'
,
gnssStatusCb
);
...
...
@@ -303,7 +303,7 @@ off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>): v
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
gnssStatusCb
=
(
satelliteStatusInfo
)
=>
{
let
gnssStatusCb
=
(
satelliteStatusInfo
:
geolocation
.
SatelliteStatusInfo
)
=>
{
console
.
log
(
'
gnssStatusChange:
'
+
JSON
.
stringify
(
satelliteStatusInfo
));
}
geolocation
.
on
(
'
gnssStatusChange
'
,
gnssStatusCb
);
...
...
@@ -337,7 +337,7 @@ on(type: 'nmeaMessageChange', callback: Callback<string>): void;
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
nmeaCb
=
(
str
)
=>
{
let
nmeaCb
=
(
str
:
string
):
void
=>
{
console
.
log
(
'
nmeaMessageChange:
'
+
JSON
.
stringify
(
str
));
}
geolocation
.
on
(
'
nmeaMessageChange
'
,
nmeaCb
);
...
...
@@ -370,7 +370,7 @@ off(type: 'nmeaMessageChange', callback?: Callback<string>): void;
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
nmeaCb
=
(
str
)
=>
{
let
nmeaCb
=
(
str
:
string
):
void
=>
{
console
.
log
(
'
nmeaMessageChange:
'
+
JSON
.
stringify
(
str
));
}
geolocation
.
on
(
'
nmeaMessageChange
'
,
nmeaCb
);
...
...
@@ -406,7 +406,7 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
import
geolocation
from
'
@ohos.geolocation
'
;
import
wantAgent
from
'
@ohos.app.ability.wantAgent
'
;
let
wantAgentInfo
=
{
let
wantAgentInfo
:
wantAgent
.
WantAgentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.myapplication
"
,
...
...
@@ -420,7 +420,7 @@ on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
};
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
let
requestInfo
=
{
'
priority
'
:
0x201
,
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
let
requestInfo
:
geolocation
.
GeofenceRequest
=
{
'
priority
'
:
0x201
,
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
geolocation
.
on
(
'
fenceStatusChange
'
,
requestInfo
,
wantAgentObj
);
});
```
...
...
@@ -454,7 +454,7 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
import
geolocation
from
'
@ohos.geolocation
'
;
import
wantAgent
from
'
@ohos.app.ability.wantAgent
'
;
let
wantAgentInfo
=
{
let
wantAgentInfo
:
wantAgent
.
WantAgentInfo
=
{
wants
:
[
{
bundleName
:
"
com.example.myapplication
"
,
...
...
@@ -468,7 +468,7 @@ off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent): void;
};
wantAgent
.
getWantAgent
(
wantAgentInfo
).
then
((
wantAgentObj
)
=>
{
let
requestInfo
=
{
'
priority
'
:
0x201
,
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
let
requestInfo
:
geolocation
.
GeofenceRequest
=
{
'
priority
'
:
0x201
,
'
scenario
'
:
0x301
,
"
geofence
"
:
{
"
latitude
"
:
121
,
"
longitude
"
:
26
,
"
radius
"
:
100
,
"
expiration
"
:
10000
}};
geolocation
.
on
(
'
fenceStatusChange
'
,
requestInfo
,
wantAgentObj
);
geolocation
.
off
(
'
fenceStatusChange
'
,
requestInfo
,
wantAgentObj
);
});
...
...
@@ -499,8 +499,9 @@ getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<L
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
err
,
location
)
=>
{
import
BusinessError
from
"
@ohos.base
"
let
requestInfo
:
geolocation
.
CurrentLocationRequest
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
maxAccuracy
'
:
0
};
let
locationChange
=
(
err
:
BusinessError
.
BusinessError
,
location
:
geolocation
.
Location
)
=>
{
if
(
err
)
{
console
.
log
(
'
locationChanger: err=
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -536,7 +537,8 @@ getCurrentLocation(callback: AsyncCallback<Location>): void
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
locationChange
=
(
err
,
location
)
=>
{
import
BusinessError
from
"
@ohos.base
"
let
locationChange
=
(
err
:
BusinessError
.
BusinessError
,
location
:
geolocation
.
Location
):
void
=>
{
if
(
err
)
{
console
.
log
(
'
locationChanger: err=
'
+
JSON
.
stringify
(
err
));
}
...
...
@@ -578,7 +580,7 @@ getCurrentLocation(request?: CurrentLocationRequest): Promise<Location>
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
maxAccuracy
'
:
0
};
let
requestInfo
:
geolocation
.
CurrentLocationRequest
=
{
'
priority
'
:
0x203
,
'
scenario
'
:
0x300
,
'
maxAccuracy
'
:
0
};
geolocation
.
getCurrentLocation
(
requestInfo
).
then
((
result
)
=>
{
console
.
log
(
'
current location:
'
+
JSON
.
stringify
(
result
));
});
...
...
@@ -863,7 +865,7 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest, callback: AsyncCallback
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest
:
geolocation
.
ReverseGeoCodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
'
getAddressesFromLocation: err=
'
+
JSON
.
stringify
(
err
));
...
...
@@ -904,7 +906,7 @@ getAddressesFromLocation(request: ReverseGeoCodeRequest): Promise<Array<Ge
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
reverseGeocodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
let
reverseGeocodeRequest
:
geolocation
.
ReverseGeoCodeRequest
=
{
"
latitude
"
:
31.12
,
"
longitude
"
:
121.11
,
"
maxItems
"
:
1
};
geolocation
.
getAddressesFromLocation
(
reverseGeocodeRequest
).
then
((
data
)
=>
{
console
.
log
(
'
getAddressesFromLocation:
'
+
JSON
.
stringify
(
data
));
});
...
...
@@ -935,7 +937,7 @@ getAddressesFromLocationName(request: GeoCodeRequest, callback: AsyncCallback<
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
geocodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
let
geocodeRequest
:
geolocation
.
GeoCodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
'
getAddressesFromLocationName: err=
'
+
JSON
.
stringify
(
err
));
...
...
@@ -976,7 +978,7 @@ getAddressesFromLocationName(request: GeoCodeRequest): Promise<Array<GeoAd
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
geocodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
let
geocodeRequest
:
geolocation
.
GeoCodeRequest
=
{
"
description
"
:
"
上海市浦东新区xx路xx号
"
,
"
maxItems
"
:
1
};
geolocation
.
getAddressesFromLocationName
(
geocodeRequest
).
then
((
result
)
=>
{
console
.
log
(
'
getAddressesFromLocationName:
'
+
JSON
.
stringify
(
result
));
});
...
...
@@ -1138,7 +1140,7 @@ sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>): v
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
scenario
'
:
0x301
,
'
command
'
:
"
command_1
"
};
let
requestInfo
:
geolocation
.
LocationCommand
=
{
'
scenario
'
:
0x301
,
'
command
'
:
"
command_1
"
};
geolocation
.
sendCommand
(
requestInfo
,
(
err
,
result
)
=>
{
if
(
err
)
{
console
.
log
(
'
sendCommand: err=
'
+
JSON
.
stringify
(
err
));
...
...
@@ -1180,7 +1182,7 @@ sendCommand(command: LocationCommand): Promise<boolean>;
```
ts
import
geolocation
from
'
@ohos.geolocation
'
;
let
requestInfo
=
{
'
scenario
'
:
0x301
,
'
command
'
:
"
command_1
"
};
let
requestInfo
:
geolocation
.
LocationCommand
=
{
'
scenario
'
:
0x301
,
'
command
'
:
"
command_1
"
};
geolocation
.
sendCommand
(
requestInfo
).
then
((
result
)
=>
{
console
.
log
(
'
promise, sendCommand:
'
+
JSON
.
stringify
(
result
));
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录