Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
Hello UTS
提交
c4c6c607
H
Hello UTS
项目概览
DCloud
/
Hello UTS
通知
1598
Star
27
Fork
9
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
2
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
Hello UTS
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
2
Issue
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
c4c6c607
编写于
9月 07, 2022
作者:
杜庆泉
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tencent location 功能+1
上级
7fff25b4
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
51 addition
and
15 deletion
+51
-15
pages/SDKIntegration/SDKIntegration.vue
pages/SDKIntegration/SDKIntegration.vue
+4
-2
uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json
...les/uts-tencentgeolocation/utssdk/app-android/config.json
+2
-2
uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts
...dules/uts-tencentgeolocation/utssdk/app-android/index.uts
+45
-11
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/TencentLocationSDK-v7.4.9.jar
...ion/utssdk/app-android/libs/TencentLocationSDK-v7.4.9.jar
+0
-0
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/TencentLocationSdk-openplatform-7.4.9.aar
...pp-android/libs/TencentLocationSdk-openplatform-7.4.9.aar
+0
-0
未找到文件。
pages/SDKIntegration/SDKIntegration.vue
浏览文件 @
c4c6c607
...
...
@@ -24,8 +24,10 @@
},
testGetlocation
:
function
(
e
){
getLocation
({
onLocationChanged
:
function
(
locationName
,
locationAddress
){
var
addressDesc
=
locationAddress
+
'
-
'
+
locationName
geocode
:
true
,
success
:
function
(
response
){
console
.
log
(
response
);
var
addressDesc
=
response
.
name
+
'
-
'
+
response
.
address
uni
.
showToast
({
title
:
'
执行结果:
'
+
addressDesc
,
icon
:
'
none
'
...
...
uni_modules/uts-tencentgeolocation/utssdk/app-android/config.json
浏览文件 @
c4c6c607
{
"libs"
:
[],
"dependencies"
:
[{
"id"
:
"androidx.core:core"
,
"source"
:
"implementation 'androidx.core:core:1.0.0'"
},
{
},
{
"id"
:
"com.tencent.map.geolocation:TencentLocationSdk-openplatform"
,
"source"
:
"implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.3.0'"
}],
...
...
uni_modules/uts-tencentgeolocation/utssdk/app-android/index.uts
浏览文件 @
c4c6c607
...
...
@@ -11,6 +11,8 @@ import Looper from "android.os.Looper";
import TencentLocationManager from "com.tencent.map.geolocation.TencentLocationManager";
import TencentLocationListener from "com.tencent.map.geolocation.TencentLocationListener";
import TencentLocation from "com.tencent.map.geolocation.TencentLocation";
import TencentLocationRequest from "com.tencent.map.geolocation.TencentLocationRequest";
export function requestPremission() {
...
...
@@ -27,7 +29,7 @@ export function requestPremission() {
console.log(requestCode);
});
// 发起权限申请
// 参考文档:https://lbs.qq.com/mobile/androidLocationSDK/androidGeoGuide/androidGeoAdapt
ActivityCompat.requestPermissions(
getUniActivity()!,
arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION), 1001);
...
...
@@ -37,11 +39,24 @@ export function requestPremission() {
}
/**
* 定位请求参数封装
*/
type LocationOptions = {
onLocationChanged: (locationName:string,locationAddress:string ) => void;
geocode:boolean,
success: (response:LocationResponse) => void;
};
/**
* 定位返回结果封装
*/
type LocationResponse = {
name?:string,
address?:string,
latitude?:number,
longitude?:number
}
class LocationOptionsWapper{
hostOption:LocationOptions;
...
...
@@ -53,16 +68,25 @@ class LocationOptionsWapper{
onLocationChanged(location:TencentLocation , error:Int ,
reason:string){
hostOption.onLocationChanged(location.name,location.address);
let response = new LocationResponse();
response.name = location.name;
response.address = location.address;
response.latitude = location.latitude;
response.longitude = location.longitude;
this.hostOption.success(response);
}
onStatusUpdate(name:string, status:Int, desc:string){
// 定位状态发生变化
//hostOption.onStatusUpdate(name,status,desc);
}
};
/**
* Tencent 定位监听实现类
*/
class SingleLocationListener extends TencentLocationListener {
...
...
@@ -75,7 +99,6 @@ class SingleLocationListener extends TencentLocationListener {
override onLocationChanged(location:TencentLocation , error:Int ,
reason:string ):void{
this.hostOptionWraper.onLocationChanged(location,error,reason);
}
...
...
@@ -85,14 +108,25 @@ class SingleLocationListener extends TencentLocationListener {
}
export function getLocation(changeListener: LocationOptions) {
/**
* 腾讯地图获取定位信息
* 参考文档:https://lbs.qq.com/mobile/androidLocationSDK/androidGeoGuide/androidGeoAdapt
*/
export function getLocation(locationOptions: LocationOptions) {
// 获取当前的地址回调
let mLocationManager = TencentLocationManager.getInstance(getAppContext());
let locationOptionWrapper = new LocationOptionsWapper(changeListener);
// 定位监听器封装
let locationOptionWrapper = new LocationOptionsWapper(locationOptions);
let mLocationListener = new SingleLocationListener(locationOptionWrapper);
// 发起单次请求
let locationRequest = TencentLocationRequest.create()
// 是否需要逆地理编码
if(locationOptions.geocode){
locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_ADMIN_AREA);
}else{
locationRequest.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_GEO);
}
mLocationManager.requestSingleFreshLocation(null, mLocationListener, Looper.getMainLooper());
// 请求权限
mLocationManager.requestSingleFreshLocation(locationRequest, mLocationListener, Looper.getMainLooper());
return { name: "getLocation"};
}
\ No newline at end of file
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/TencentLocationSDK-v7.4.9.jar
已删除
100644 → 0
浏览文件 @
7fff25b4
文件已删除
uni_modules/uts-tencentgeolocation/utssdk/app-android/libs/TencentLocationSdk-openplatform-7.4.9.aar
0 → 100644
浏览文件 @
c4c6c607
文件已添加
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录