Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5c426976
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看板
未验证
提交
5c426976
编写于
7月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
7月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!7052 修改VOD问题,修改文档问题
Merge pull request !7052 from 刘彬俊/master
上级
5531da6a
3544974d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
18 deletion
+67
-18
en/application-dev/device/device-location-geocoding.md
en/application-dev/device/device-location-geocoding.md
+25
-5
en/application-dev/device/device-location-info.md
en/application-dev/device/device-location-info.md
+8
-4
zh-cn/application-dev/device/device-location-geocoding.md
zh-cn/application-dev/device/device-location-geocoding.md
+26
-5
zh-cn/application-dev/device/device-location-info.md
zh-cn/application-dev/device/device-location-info.md
+8
-4
未找到文件。
en/application-dev/device/device-location-geocoding.md
浏览文件 @
5c426976
...
...
@@ -36,13 +36,29 @@ The following table describes APIs available for mutual conversion between coord
import geolocation from '@ohos.geolocation';
```
2.
Obtain the conversion result.
2.
Query whether geocoder service is available.
-
Call
**isGeoServiceAvailable**
to query whether the geocoder service is available. If the service is available, continue with step 3.
```
geolocation.isGeoServiceAvailable((err, data) => {
if (err) {
console.log('isGeoServiceAvailable err: ' + JSON.stringify(err));
} else {
console.log('isGeoServiceAvailable data: ' + JSON.stringify(data));
}
});
```
3.
Obtain the conversion result.
-
Call
**getAddressesFromLocation**
to convert coordinates into geographical location information.
```
var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (data) => {
console.log('getAddressesFromLocation: ' + JSON.stringify(data));
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) {
console.log('getAddressesFromLocation err: ' + JSON.stringify(err));
} else {
console.log('getAddressesFromLocation data: ' + JSON.stringify(data));
}
});
```
...
...
@@ -51,8 +67,12 @@ The following table describes APIs available for mutual conversion between coord
```
var geocodeRequest = {"description": "No. xx, xx Road, Pudong District, Shanghai", "maxItems": 1};
geolocation.getAddressesFromLocationName(geocodeRequest, (data) => {
console.log('getAddressesFromLocationName: ' + JSON.stringify(data));
geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
if (err) {
console.log('getAddressesFromLocationName err: ' + JSON.stringify(err));
} else {
console.log('getAddressesFromLocationName data: ' + JSON.stringify(data));
}
});
```
...
...
en/application-dev/device/device-location-info.md
浏览文件 @
5c426976
...
...
@@ -123,7 +123,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
The following example instantiates the **RequestParam** object for navigation:
```
var requestInfo = {'scenario':
0x301
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
var requestInfo = {'scenario':
geolocation.LocationRequestScenario.NAVIGATION
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
**Method 2:**
...
...
@@ -152,7 +152,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
The following example instantiates the **RequestParam** object for the location accuracy priority policy:
```
var requestInfo = {'priority':
0x201
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
var requestInfo = {'priority':
geolocation.LocationRequestPriority.ACCURACY
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
4.
Instantiate the
**Callback**
object for the system to report location results.
...
...
@@ -179,8 +179,12 @@ To learn more about the APIs for obtaining device location information, see [Geo
If your application does not need the real-time device location, it can use the last known device location cached in the system instead.
```
geolocation.getLastLocation((data) => {
console.log('getLastLocation: data: ' + JSON.stringify(data));
geolocation.getLastLocation((err, data) => {
if (err) {
console.log('getLastLocation: err: ' + JSON.stringify(err));
} else {
console.log('getLastLocation: data: ' + JSON.stringify(data));
}
});
```
...
...
zh-cn/application-dev/device/device-location-geocoding.md
浏览文件 @
5c426976
...
...
@@ -39,13 +39,30 @@
import geolocation from '@ohos.geolocation';
```
2.
获取转化结果。
2.
查询geoCoder服务是否可用。
-
调用isGeoServiceAvailable查询geoCoder服务是否可用,如果服务可用再继续进行步骤3。
```
geolocation.isGeoServiceAvailable((err, data) => {
if (err) {
console.log('isGeoServiceAvailable err: ' + JSON.stringify(err));
} else {
console.log('isGeoServiceAvailable data: ' + JSON.stringify(data));
}
});
```
3.
获取转化结果。
-
调用getAddressesFromLocation,坐标转化地理位置信息。
```
var reverseGeocodeRequest = {"latitude": 31.12, "longitude": 121.11, "maxItems": 1};
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (data) => {
console.log('getAddressesFromLocation: ' + JSON.stringify(data));
geolocation.getAddressesFromLocation(reverseGeocodeRequest, (err, data) => {
if (err) {
console.log('getAddressesFromLocation err: ' + JSON.stringify(err));
} else {
console.log('getAddressesFromLocation data: ' + JSON.stringify(data));
}
});
```
...
...
@@ -54,8 +71,12 @@
```
var geocodeRequest = {"description": "上海市浦东新区xx路xx号", "maxItems": 1};
geolocation.getAddressesFromLocationName(geocodeRequest, (data) => {
console.log('getAddressesFromLocationName: ' + JSON.stringify(data));
geolocation.getAddressesFromLocationName(geocodeRequest, (err, data) => {
if (err) {
console.log('getAddressesFromLocationName err: ' + JSON.stringify(err));
} else {
console.log('getAddressesFromLocationName data: ' + JSON.stringify(data));
}
});
```
...
...
zh-cn/application-dev/device/device-location-info.md
浏览文件 @
5c426976
...
...
@@ -123,7 +123,7 @@
以导航场景为例,实例化方式如下:
```
var requestInfo = {'scenario':
0x301
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
var requestInfo = {'scenario':
geolocation.LocationRequestScenario.NAVIGATION
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
**方式二:**
...
...
@@ -152,7 +152,7 @@
以定位精度优先策略为例,实例化方式如下:
```
var requestInfo = {'priority':
0x201
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
var requestInfo = {'priority':
geolocation.LocationRequestPriority.ACCURACY
, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
```
4.
实例化Callback对象,用于向系统提供位置上报的途径。
...
...
@@ -179,8 +179,12 @@
如果应用使用场景不需要实时的设备位置,可以获取系统缓存的最近一次历史定位结果。
```
geolocation.getLastLocation((data) => {
console.log('getLastLocation: data: ' + JSON.stringify(data));
geolocation.getLastLocation((err, data) => {
if (err) {
console.log('getLastLocation: err: ' + JSON.stringify(err));
} else {
console.log('getLastLocation: data: ' + JSON.stringify(data));
}
});
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录