Merge branch 'positions' into appbase
@ -1,6 +1,11 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
// 本地 Maven 仓库(默认路径为 ~/.m2/repository)
|
||||
mavenLocal()
|
||||
// 或自定义本地仓库路径
|
||||
maven { url "file:///sdcard/.m2/repository" }
|
||||
|
||||
// Nexus Maven 库地址
|
||||
// "WinBoll Release"
|
||||
maven { url "https://nexus.winboll.cc/repository/maven-public/" }
|
||||
@ -15,7 +20,7 @@ buildscript {
|
||||
maven { url "https://jitpack.io" }
|
||||
mavenCentral()
|
||||
google()
|
||||
mavenLocal()
|
||||
//mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.2.1' // 对应 compileSdkVersion 32
|
||||
|
@ -1,8 +1,10 @@
|
||||
# Positions
|
||||
本项目涉及个人隐私,现转为个人应用开发。项目源码正式停止公开维护。
|
||||
|
||||
#### 介绍
|
||||
位置应用,与卫星定位有关的应用。可以根据设定的位置与时间条件判断,来发送通知的应用。
|
||||
|
||||
|
||||
#### 软件架构
|
||||
以腾讯位置服务SDK源码为基础。源码地址:https://lbs.qq.com/mobile/androidMapSDK/developerGuide/configuration
|
||||
适配安卓应用 [AIDE Pro] 的 Gradle 编译结构。
|
||||
|
@ -51,34 +51,64 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
// 定位服务
|
||||
implementation 'com.google.android.gms:play-services-location:20.0.0'
|
||||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.viewpager:viewpager:1.0.0'
|
||||
implementation 'androidx.fragment:fragment:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.4.0'
|
||||
implementation 'pub.devrel:easypermissions:2.0.1'
|
||||
// 地图
|
||||
implementation 'com.tencent.map:tencent-map-vector-sdk:6.2.1.250120.3f971009.140342819'
|
||||
// 基础库
|
||||
implementation 'com.tencent.openmap:foundation:0.5.6.9be4e02'
|
||||
implementation 'com.tencent.map:sdk-utilities:1.0.9'
|
||||
implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.5.4.3'
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
api 'com.google.android.gms:play-services-location:20.0.0'
|
||||
|
||||
implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||
implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 腾讯地图
|
||||
//api 'com.tencent.map:tencent-map-vector-sdk:6.2.1.250120.3f971009.140342819'
|
||||
// 地图库
|
||||
api 'com.tencent.map:tencent-map-vector-sdk:4.5.6'
|
||||
// 地图组件库,包括小车平移、点聚合等组件功能,详见开发指南。
|
||||
api 'com.tencent.map:sdk-utilities:1.0.6'
|
||||
//api 'com.tencent.openmap:foundation:0.5.6.9be4e02'
|
||||
api 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.5.4.3'
|
||||
|
||||
implementation 'cc.winboll.studio:libapputils:9.3.2'
|
||||
implementation 'cc.winboll.studio:libappbase:1.5.6'
|
||||
api 'com.google.code.gson:gson:2.8.5'
|
||||
// 权限申请框架
|
||||
//implementation 'pub.devrel:easypermissions:2.0.1'
|
||||
// 权限申请框架:https://github.com/getActivity/XXPermissions
|
||||
//implementation 'com.github.getActivity:XXPermissions:18.63'
|
||||
// 下拉控件
|
||||
api 'com.baoyz.pullrefreshlayout:library:1.2.0'
|
||||
// 拼音搜索
|
||||
// https://mvnrepository.com/artifact/com.github.open-android/pinyin4j
|
||||
//implementation 'com.github.open-android:pinyin4j:2.5.0'
|
||||
// SSH
|
||||
//implementation 'com.jcraft:jsch:0.1.55'
|
||||
// Html 解析
|
||||
//implementation 'org.jsoup:jsoup:1.13.1'
|
||||
// 二维码类库
|
||||
api 'com.google.zxing:core:3.4.1'
|
||||
api 'com.journeyapps:zxing-android-embedded:3.6.0'
|
||||
// 应用介绍页类库
|
||||
//implementation 'io.github.medyo:android-about-page:2.0.0'
|
||||
// 吐司类库
|
||||
//implementation 'com.github.getActivity:ToastUtils:10.5'
|
||||
// 网络连接类库
|
||||
api 'com.squareup.okhttp3:okhttp:4.4.1'
|
||||
|
||||
// AndroidX 类库
|
||||
api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'com.google.android.material:material:1.4.0'
|
||||
//api 'androidx.viewpager:viewpager:1.0.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
//api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
//api 'androidx.fragment:fragment:1.1.0'
|
||||
|
||||
api 'cc.winboll.studio:libaes:15.2.6'
|
||||
api 'cc.winboll.studio:libapputils:15.2.2'
|
||||
api 'cc.winboll.studio:libappbase:15.2.2'
|
||||
|
||||
/*api 'androidx.appcompat:appcompat:1.1.0'
|
||||
api 'androidx.viewpager:viewpager:1.0.0'
|
||||
api 'androidx.vectordrawable:vectordrawable:1.1.0'
|
||||
api 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
|
||||
api 'androidx.fragment:fragment:1.1.0'
|
||||
api 'com.google.android.material:material:1.3.0'
|
||||
*/
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Tue Feb 25 05:04:52 GMT 2025
|
||||
#Mon Apr 07 16:13:21 GMT 2025
|
||||
stageCount=0
|
||||
libraryProject=
|
||||
baseVersion=1.0
|
||||
publishVersion=1.0.0
|
||||
buildCount=184
|
||||
buildCount=459
|
||||
baseBetaVersion=1.0.1
|
||||
|
BIN
positions/src/.DS_Store
vendored
BIN
positions/src/main/.DS_Store
vendored
@ -25,7 +25,7 @@
|
||||
<!-- 只能在前台获取精确的位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
|
||||
<!-- 只能在前台获取大概位置(基于网络) -->
|
||||
<!-- 只有在前台运行时才能获取大致位置信息 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
|
||||
<!-- 连接WLAN网络和断开连接 -->
|
||||
@ -35,6 +35,8 @@
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
tools:replace="android:appComponentFactory"
|
||||
android:appComponentFactory="androidx.core.app.CoreComponentFactory"
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
@ -44,10 +46,9 @@
|
||||
android:theme="@style/MyAppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning"
|
||||
tools:targetApi="q">
|
||||
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
|
||||
|
||||
<activity android:name=".MainSimpleActivity">
|
||||
<activity android:name=".MainActivity">
|
||||
|
||||
<intent-filter>
|
||||
|
||||
@ -59,7 +60,7 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".MainActivity2">
|
||||
<activity android:name=".MainSimpleActivity">
|
||||
|
||||
</activity>
|
||||
|
||||
@ -736,6 +737,10 @@
|
||||
|
||||
<activity android:name="cc.winboll.studio.positions.activities.TestMapViewActivity"/>
|
||||
|
||||
<activity android:name="cc.winboll.studio.positions.activities.JointPositioningActivity"/>
|
||||
|
||||
<service android:name="cc.winboll.studio.positions.services.GPSService"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 6.4 KiB |
@ -1,50 +0,0 @@
|
||||
31.23037 121.4737 40.07733 116.60039 45.0
|
||||
30.5702 104.06476 40.07733 116.60039 45.0
|
||||
22.54286 114.05956 40.07733 116.60039 45.0
|
||||
23.12908 113.26436 40.07733 116.60039 45.0
|
||||
29.56471 106.55073 40.07733 116.60039 45.0
|
||||
30.27415 120.15515 40.07733 116.60039 45.0
|
||||
24.87966 102.83322 40.07733 116.60039 45.0
|
||||
34.32932 108.70929 40.07733 116.60039 45.0
|
||||
45.80216 126.5358 40.07733 116.60039 45.0
|
||||
28.22778 112.93886 40.07733 116.60039 45.0
|
||||
18.25248 109.51209 40.07733 116.60039 45.0
|
||||
43.82663 87.61688 40.07733 116.60039 45.0
|
||||
30.59276 114.30525 40.07733 116.60039 45.0
|
||||
22.27534 114.16546 40.07733 116.60039 45.0
|
||||
26.64702 106.63024 40.07733 116.60039 45.0
|
||||
24.47951 118.08948 40.07733 116.60039 45.0
|
||||
20.04422 110.19989 40.07733 116.60039 45.0
|
||||
28.68202 115.85794 40.07733 116.60039 45.0
|
||||
43.81602 125.32357 40.07733 116.60039 45.0
|
||||
36.06623 120.38299 40.07733 116.60039 45.0
|
||||
22.81673 108.3669 40.07733 116.60039 45.0
|
||||
26.07421 119.29647 40.07733 116.60039 45.0
|
||||
38.91369 121.61476 40.07733 116.60039 45.0
|
||||
41.80563 123.43236 40.07733 116.60039 45.0
|
||||
32.05838 118.79647 40.07733 116.60039 45.0
|
||||
36.06138 103.83417 40.07733 116.60039 45.0
|
||||
38.48644 106.23248 40.07733 116.60039 45.0
|
||||
27.99492 120.69939 40.07733 116.60039 45.0
|
||||
37.46353 121.44801 40.07733 116.60039 45.0
|
||||
22.27073 113.57668 40.07733 116.60039 45.0
|
||||
29.87386 121.55027 40.07733 116.60039 45.0
|
||||
31.82057 117.22901 40.07733 116.60039 45.0
|
||||
34.34127 108.93984 40.07733 116.60039 45.0
|
||||
49.21163 119.76584 40.07733 116.60039 45.0
|
||||
40.84149 111.75199 40.07733 116.60039 45.0
|
||||
37.87059 112.55067 40.07733 116.60039 45.0
|
||||
46.58758 125.10307 40.07733 116.60039 45.0
|
||||
25.27361 110.29002 40.07733 116.60039 45.0
|
||||
31.46751 104.6796 40.07733 116.60039 45.0
|
||||
24.87389 118.67587 40.07733 116.60039 45.0
|
||||
30.69186 111.28642 40.07733 116.60039 45.0
|
||||
23.54972 116.37271 40.07733 116.60039 45.0
|
||||
40.65781 109.84021 40.07733 116.60039 45.0
|
||||
37.51348 122.12171 40.07733 116.60039 45.0
|
||||
31.49099 120.31237 40.07733 116.60039 45.0
|
||||
22.18684 113.54294 40.07733 116.60039 45.0
|
||||
34.74725 113.62493 40.07733 116.60039 45.0
|
||||
34.61812 112.45361 40.07733 116.60039 45.0
|
||||
36.50204 102.104287 40.07733 116.60039 45.0
|
||||
24.954708 121.48068 40.07733 116.60039 45.0
|
@ -1,10 +0,0 @@
|
||||
39.90469 116.40717 29.56471 106.55073 30.0
|
||||
39.90469 116.40717 39.53775 116.68376 30.0
|
||||
39.90469 116.40717 31.23037 121.4737 30.0
|
||||
39.90469 116.40717 23.12908 113.26436 30.0
|
||||
39.90469 116.40717 28.22778 112.93886 30.0
|
||||
29.56471 106.55073 39.90469 116.40717 60.0
|
||||
18.25248 109.51209 39.90469 116.40717 60.0
|
||||
31.23037 121.4737 39.90469 116.40717 60.0
|
||||
23.12908 113.26436 39.90469 116.40717 60.0
|
||||
39.53775 116.68376 39.90469 116.40717 60.0
|
@ -1,25 +0,0 @@
|
||||
116.307621 39.984059
|
||||
116.304703 39.981954
|
||||
116.312256 39.984355
|
||||
116.315346 39.980442
|
||||
116.308994 39.981527
|
||||
116.310539 39.979751
|
||||
116.305776 39.977252
|
||||
116.316419 39.984026
|
||||
116.314874 39.976956
|
||||
116.311827 39.978501
|
||||
116.312814 39.980277
|
||||
116.369022 39.980236
|
||||
116.368486 39.980236
|
||||
116.367488 39.977161
|
||||
116.396713 39.915398
|
||||
116.455421 39.937645
|
||||
116.321182 39.896304
|
||||
121.452827 31.254487
|
||||
121.485443 31.225133
|
||||
121.442528 31.216912
|
||||
121.500893 31.251552
|
||||
121.455917 31.249204
|
||||
114.042892 22.546885
|
||||
113.999805 22.538086
|
||||
114.082031 22.538086
|
Before Width: | Height: | Size: 781 B |
Before Width: | Height: | Size: 712 B |
Before Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 49 KiB |
BIN
positions/src/main/java/.DS_Store
vendored
@ -7,23 +7,32 @@ package cc.winboll.studio.positions;
|
||||
*/
|
||||
import cc.winboll.studio.libappbase.GlobalApplication;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import java.io.File;
|
||||
import cc.winboll.studio.libappbase.winboll.WinBollActivityManager;
|
||||
|
||||
public class App extends GlobalApplication {
|
||||
|
||||
public static final String TAG = "App";
|
||||
public static String szDataFolder = "";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
// 必须在调用基类前设置应用调试标志,
|
||||
// 这样可以预先设置日志与数据的存储根目录。
|
||||
setIsDebuging(this, BuildConfig.DEBUG);
|
||||
super.onCreate();
|
||||
// 设置 WinBoll 应用 UI 类型
|
||||
WinBollActivityManager.getInstance(this).setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Aplication);
|
||||
getWinBollActivityManager().setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Aplication);
|
||||
|
||||
|
||||
LogUtils.d(TAG, "onCreate");
|
||||
if (BuildConfig.DEBUG) {
|
||||
szDataFolder = getExternalFilesDir(TAG).toString();
|
||||
} else {
|
||||
szDataFolder = getFilesDir().toString() + File.separator + TAG;
|
||||
}
|
||||
File fDataFolder = new File(szDataFolder);
|
||||
if (!fDataFolder.exists()) {
|
||||
fDataFolder.mkdirs();
|
||||
}
|
||||
LogUtils.d(TAG, String.format("Data path is : %s", szDataFolder));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.telecom.TelecomManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@ -15,28 +14,32 @@ import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.libapputils.app.IWinBollActivity;
|
||||
import cc.winboll.studio.libapputils.app.WinBollActivityManager;
|
||||
import cc.winboll.studio.libapputils.bean.APPInfo;
|
||||
import cc.winboll.studio.libapputils.view.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.DemoMainActivity;
|
||||
import cc.winboll.studio.positions.activities.AbsActivity;
|
||||
import cc.winboll.studio.positions.activities.JointPositioningActivity;
|
||||
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||
import cc.winboll.studio.positions.adapters.MyPagerAdapter;
|
||||
import cc.winboll.studio.positions.beans.MainServiceBean;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import cc.winboll.studio.positions.fragments.LogFragment;
|
||||
import cc.winboll.studio.positions.fragments.PositionsFragment;
|
||||
import cc.winboll.studio.positions.fragments.TXMSFragment;
|
||||
import cc.winboll.studio.positions.fragments.TasksFragment;
|
||||
import cc.winboll.studio.positions.models.MainServiceBean;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.tencent.map.vector.demo.AbsListActivity;
|
||||
import com.tencent.map.vector.demo.AbsActivity;
|
||||
import cc.winboll.studio.positions.listeners.OnTXRTLocationListener;
|
||||
import android.location.Location;
|
||||
|
||||
final public class MainSimpleActivity extends AbsActivity implements IWinBollActivity, ViewPager.OnPageChangeListener, View.OnClickListener {
|
||||
final public class MainActivity extends AbsActivity implements IWinBollActivity, ViewPager.OnPageChangeListener, View.OnClickListener {
|
||||
|
||||
public static final String TAG = "MainActivity";
|
||||
|
||||
@ -45,11 +48,22 @@ final public class MainSimpleActivity extends AbsActivity implements IWinBollAct
|
||||
|
||||
public static final String ACTION_SOS = "cc.winboll.studio.libappbase.WinBoll.ACTION_SOS";
|
||||
|
||||
static MainActivity _MainActivity;
|
||||
|
||||
// 创建Fragment列表和标题列表
|
||||
List<Fragment> fragmentList = new ArrayList<>();
|
||||
List<String> tabTitleList = new ArrayList<>();
|
||||
|
||||
TXMSFragment mTXMSFragment;
|
||||
PositionsFragment mPositionsFragment;
|
||||
TasksFragment mTasksFragment;
|
||||
LogFragment mLogFragment;
|
||||
LogView mLogView;
|
||||
Toolbar mToolbar;
|
||||
CheckBox cbMainService;
|
||||
MainServiceBean mMainServiceBean;
|
||||
ViewPager viewPager;
|
||||
private TabLayout tabLayout;
|
||||
private ViewPager viewPager;
|
||||
private List<View> views; //用来存放放进ViewPager里面的布局
|
||||
//实例化存储imageView(导航原点)的集合
|
||||
ImageView[] imageViews;
|
||||
@ -60,104 +74,117 @@ final public class MainSimpleActivity extends AbsActivity implements IWinBollAct
|
||||
|
||||
private static final int DIALER_REQUEST_CODE = 1;
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
// String szBranchName = "contacts";
|
||||
//
|
||||
// APPInfo appInfo = AboutActivityFactory.buildDefaultAPPInfo();
|
||||
// appInfo.setAppName("Contacts");
|
||||
// appInfo.setAppIcon(cc.winboll.studio.libapputils.R.drawable.ic_winboll);
|
||||
// appInfo.setAppDescription("Contacts Description");
|
||||
// appInfo.setAppGitName("APP");
|
||||
// appInfo.setAppGitOwner("Studio");
|
||||
// appInfo.setAppGitAPPBranch(szBranchName);
|
||||
// appInfo.setAppGitAPPSubProjectFolder(szBranchName);
|
||||
// appInfo.setAppHomePage("https://www.winboll.cc/studio/details.php?app=Contacts");
|
||||
// appInfo.setAppAPKName("Contacts");
|
||||
// appInfo.setAppAPKFolderName("Contacts");
|
||||
// return appInfo;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
// 接收并处理 Intent 数据,函数 Intent 处理接收就直接返回
|
||||
//if (prosessIntents(getIntent())) return;
|
||||
// 以下正常创建主窗口
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
_MainActivity = this;
|
||||
|
||||
// 初始化工具栏
|
||||
mToolbar = findViewById(R.id.activitymainToolbar1);
|
||||
setSupportActionBar(mToolbar);
|
||||
if (isEnableDisplayHomeAsUp()) {
|
||||
// 显示后退按钮
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setSubtitle(getTag());
|
||||
// mToolbar = findViewById(R.id.toolbar);
|
||||
// setActionBar(mToolbar);
|
||||
//// if (isEnableDisplayHomeAsUp()) {
|
||||
//// // 显示后退按钮
|
||||
//// getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
//// }
|
||||
// getActionBar().setTitle("");
|
||||
|
||||
initData();
|
||||
initView();
|
||||
//initPoint();//调用初始化导航原点的方法
|
||||
viewPager.addOnPageChangeListener(this);//滑动事件
|
||||
// 初始化地图视图
|
||||
// 创建Fragment实例
|
||||
mTXMSFragment = new TXMSFragment();
|
||||
// 获取FragmentTransaction
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
// 将Fragment添加到FrameLayout容器中
|
||||
transaction.add(R.id.frameLayout, mTXMSFragment);
|
||||
transaction.commit();
|
||||
|
||||
ViewPager viewPager = findViewById(R.id.activitymainViewPager1);
|
||||
MyPagerAdapter pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
TabLayout tabLayout = findViewById(R.id.activitymainTabLayout1);
|
||||
tabLayout = findViewById(R.id.tabLayout);
|
||||
viewPager = findViewById(R.id.viewPager);
|
||||
|
||||
mPositionsFragment = new PositionsFragment();
|
||||
fragmentList.add(mPositionsFragment);
|
||||
tabTitleList.add("位置");
|
||||
|
||||
mTasksFragment = new TasksFragment();
|
||||
fragmentList.add(mTasksFragment);
|
||||
tabTitleList.add("任务");
|
||||
|
||||
|
||||
mLogFragment = new LogFragment();
|
||||
fragmentList.add(mLogFragment);
|
||||
tabTitleList.add("日志");
|
||||
|
||||
|
||||
|
||||
// 设置ViewPager的适配器
|
||||
MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
|
||||
// 关联TabLayout和ViewPager
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
|
||||
mTXMSFragment.setOnTXRTLocationListener(new OnTXRTLocationListener(){
|
||||
@Override
|
||||
public void onTXRTLocation(Location location) {
|
||||
mPositionsFragment.showLocationTX(location);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void startTXRTLocation(){
|
||||
mTXMSFragment.startRTLocation();
|
||||
}
|
||||
|
||||
// mMainServiceBean = MainServiceBean.loadBean(this, MainServiceBean.class);
|
||||
// if (mMainServiceBean == null) {
|
||||
// mMainServiceBean = new MainServiceBean();
|
||||
// }
|
||||
// cbMainService = findViewById(R.id.activitymainCheckBox1);
|
||||
// cbMainService.setChecked(mMainServiceBean.isEnable());
|
||||
// cbMainService.setOnClickListener(new View.OnClickListener(){
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// if (cbMainService.isChecked()) {
|
||||
// MainService.startMainService(MainActivity.this);
|
||||
// } else {
|
||||
// MainService.stopMainService(MainActivity.this);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
MainService.startMainService(Main2Activity.this);
|
||||
// ViewPager的适配器
|
||||
public class MyPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private static final int PAGE_COUNT = 3;
|
||||
|
||||
public MyPagerAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
// 根据position返回不同的Fragment
|
||||
return fragmentList.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// 返回页面总数
|
||||
return PAGE_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return tabTitleList.get(position);
|
||||
}
|
||||
}
|
||||
|
||||
//初始化view,即显示的图片
|
||||
void initView() {
|
||||
viewPager = findViewById(R.id.activitymainViewPager1);
|
||||
pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(pagerAdapter);
|
||||
//adapter = new MyPagerAdapter(views);
|
||||
//viewPager = findViewById(R.id.activitymainViewPager1);
|
||||
//viewPager.setAdapter(adapter);
|
||||
//linearLayout = findViewById(R.id.activitymainLinearLayout1);
|
||||
//initPoint();//初始化页面下方的点
|
||||
viewPager.setOnPageChangeListener(this);
|
||||
|
||||
}
|
||||
// void initViewPager() {
|
||||
// pagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
|
||||
// mViewPager.setAdapter(pagerAdapter);
|
||||
// //adapter = new MyPagerAdapter(views);
|
||||
// //viewPager = findViewById(R.id.activitymainViewPager1);
|
||||
// //viewPager.setAdapter(adapter);
|
||||
// //linearLayout = findViewById(R.id.activitymainLinearLayout1);
|
||||
// //initPoint();//初始化页面下方的点
|
||||
// mViewPager.setOnPageChangeListener(this);
|
||||
// }
|
||||
|
||||
//初始化所要显示的布局
|
||||
void initData() {
|
||||
ViewPager viewPager = findViewById(R.id.activitymainViewPager1);
|
||||
LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||
View view1 = inflater.inflate(R.layout.fragment_gms, viewPager, false);
|
||||
View view2 = inflater.inflate(R.layout.fragment_contacts, viewPager, false);
|
||||
View view3 = inflater.inflate(R.layout.fragment_log, viewPager, false);
|
||||
|
||||
views = new ArrayList<>();
|
||||
views.add(view1);
|
||||
views.add(view2);
|
||||
views.add(view3);
|
||||
}
|
||||
// void initLayoutData() {
|
||||
// LayoutInflater inflater = LayoutInflater.from(getActivity());
|
||||
// View view1 = inflater.inflate(R.layout.fragment_gms, mViewPager, false);
|
||||
// View view2 = inflater.inflate(R.layout.fragment_contacts, mViewPager, false);
|
||||
// View view3 = inflater.inflate(R.layout.fragment_log, mViewPager, false);
|
||||
//
|
||||
// views = new ArrayList<>();
|
||||
// views.add(view1);
|
||||
// views.add(view2);
|
||||
// views.add(view3);
|
||||
// }
|
||||
|
||||
// void initPoint() {
|
||||
// imageViews = new ImageView[5];//实例化5个图片
|
||||
@ -225,90 +252,35 @@ final public class MainSimpleActivity extends AbsActivity implements IWinBollAct
|
||||
LogUtils.d(TAG, "onDestroy() SOS");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// 处理传入的 Intent 数据
|
||||
//
|
||||
// boolean prosessIntents(Intent intent) {
|
||||
// if (intent == null
|
||||
// || intent.getAction() == null
|
||||
// || intent.getAction().equals(""))
|
||||
// return false;
|
||||
//
|
||||
// if (intent.getAction().equals(StringToQrCodeView.ACTION_UNITTEST_QRCODE)) {
|
||||
// try {
|
||||
// WinBollActivity clazzActivity = UnitTestActivity.class.newInstance();
|
||||
// String tag = clazzActivity.getTag();
|
||||
// LogUtils.d(TAG, "String tag = clazzActivity.getTag(); tag " + tag);
|
||||
// Intent subIntent = new Intent(this, UnitTestActivity.class);
|
||||
// subIntent.setAction(intent.getAction());
|
||||
// File file = new File(getCacheDir(), UUID.randomUUID().toString());
|
||||
// //取出文件uri
|
||||
// Uri uri = intent.getData();
|
||||
// if (uri == null) {
|
||||
// uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
// }
|
||||
// //获取文件真实地址
|
||||
// String szSrcPath = UriUtils.getFileFromUri(getApplication(), uri);
|
||||
// if (TextUtils.isEmpty(szSrcPath)) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// Files.copy(Paths.get(szSrcPath), Paths.get(file.getPath()));
|
||||
// //startWinBollActivity(subIntent, tag);
|
||||
// WinBollActivityManager.getInstance(this).startWinBollActivity(this, subIntent, UnitTestActivity.class);
|
||||
// } catch (IllegalAccessException | InstantiationException | IOException e) {
|
||||
// LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
// // 函数处理异常返回失败
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// LogUtils.d(TAG, "prosessIntents|" + intent.getAction() + "|yet");
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activitymainToolbar1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
public Activity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
exit();
|
||||
//exit();
|
||||
}
|
||||
|
||||
void exit() {
|
||||
YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
};
|
||||
YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener);
|
||||
}
|
||||
// void exit() {
|
||||
// YesNoAlertDialog.OnDialogResultListener listener = new YesNoAlertDialog.OnDialogResultListener(){
|
||||
//
|
||||
// @Override
|
||||
// public void onYes() {
|
||||
// WinBollActivityManager.getInstance(getApplicationContext()).finishAll();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNo() {
|
||||
// }
|
||||
// };
|
||||
// YesNoAlertDialog.show(this, "[ " + getString(R.string.app_name) + " ]", "Exit(Yes/No).\nIs close all activity?", listener);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
@ -323,10 +295,18 @@ final public class MainSimpleActivity extends AbsActivity implements IWinBollAct
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_demomain) {
|
||||
Intent intent = new Intent(this, com.tencent.map.vector.demo.DemoMainActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_joint_positioning) {
|
||||
Intent intent = new Intent(this, JointPositioningActivity.class);
|
||||
startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_demomain) {
|
||||
// Intent intent = new Intent(this, com.tencent.map.vector.demo.DemoMainActivity.class);
|
||||
// startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_positionnow) {
|
||||
mTXMSFragment.sendRealTimePositioningMessage();
|
||||
} else if (item.getItemId() == R.id.item_addnewposition) {
|
||||
ToastUtils.show("item_addnewpositon");
|
||||
}
|
||||
// } else
|
||||
// if (item.getItemId() == R.id.item_exit) {
|
||||
@ -386,7 +366,7 @@ final public class MainSimpleActivity extends AbsActivity implements IWinBollAct
|
||||
// }
|
||||
if (requestCode == DIALER_REQUEST_CODE) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
Toast.makeText(Main2Activity.this, getString(R.string.app_name) + " 已成为默认电话应用",
|
||||
Toast.makeText(MainActivity.this, getString(R.string.app_name) + " 已成为默认电话应用",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import cc.winboll.studio.libappbase.LogView;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||
import cc.winboll.studio.positions.activities.TestMapViewActivity;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import cc.winboll.studio.positions.utils.LocationFileStorage;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
@ -51,10 +52,9 @@ import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
import cc.winboll.studio.positions.beans.LocationJson;
|
||||
//import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
public class MainSimpleActivity extends AppCompatActivity implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener {
|
||||
public class MainSimpleActivity extends AppCompatActivity implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener {
|
||||
|
||||
public static final String TAG ="MainSimpleActivity";
|
||||
|
||||
@ -69,7 +69,7 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
private TencentLocationManager locationManager;
|
||||
private TencentLocationRequest locationRequest;
|
||||
private MyLocationStyle locationStyle;
|
||||
ArrayList<LocationJson> locationJsonList;
|
||||
ArrayList<PostionModel> locationJsonList;
|
||||
LogView mLogView;
|
||||
|
||||
@Override
|
||||
@ -77,7 +77,7 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main_simple);
|
||||
|
||||
locationJsonList = new ArrayList<LocationJson>();
|
||||
locationJsonList = new ArrayList<PostionModel>();
|
||||
|
||||
// 初始化工具栏
|
||||
mToolbar = findViewById(R.id.activitymainToolbar1);
|
||||
@ -87,8 +87,9 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
mLogView = findViewById(R.id.logview);
|
||||
mLogView.start();
|
||||
|
||||
TencentMapInitializer.setAgreePrivacy(this, true);
|
||||
TencentMapInitializer.start(this);
|
||||
TencentMapInitializer.setAgreePrivacy(true);
|
||||
//TencentMapInitializer.setAgreePrivacy(this, true);
|
||||
//TencentMapInitializer.start(this);
|
||||
TencentLocationManager.setUserAgreePrivacy(true);
|
||||
|
||||
|
||||
@ -114,34 +115,34 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
//建立定位
|
||||
//initLocation();
|
||||
//对地图操作类进行操作
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(22.984066, 116.307548),
|
||||
15,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
// CameraUpdate cameraSigma =
|
||||
// CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
// new LatLng(22.984066, 116.307548),
|
||||
// 15f,
|
||||
// 0f,
|
||||
// 0f));
|
||||
// //移动地图
|
||||
// tencentMap.moveCamera(cameraSigma);
|
||||
|
||||
// 设置地图点击监听
|
||||
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener(){
|
||||
|
||||
@Override
|
||||
public void onMapClick(com.tencent.tencentmap.mapsdk.maps.model.LatLng latLng) {
|
||||
//创建Marker对象之前,设置属性
|
||||
//LatLng position = new LatLng(40.011313,116.391907);
|
||||
BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
||||
Location location = createLocationFromLatLng(latLng);
|
||||
addLocationJson(location);
|
||||
Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||
|
||||
//创建Marker对象之后,修改属性
|
||||
// Animation animation = new AlphaAnimation(0.7f, 0f);
|
||||
// animation.setDuration(2000);
|
||||
// mCustomMarker.setAnimation(animation);
|
||||
// mCustomMarker.startAnimation();
|
||||
}
|
||||
});
|
||||
// // 设置地图点击监听
|
||||
// tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener(){
|
||||
//
|
||||
// @Override
|
||||
// public void onMapClick(com.tencent.tencentmap.mapsdk.maps.model.LatLng latLng) {
|
||||
// //创建Marker对象之前,设置属性
|
||||
// //LatLng position = new LatLng(40.011313,116.391907);
|
||||
// BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
||||
// Location location = createLocationFromLatLng(latLng);
|
||||
// addLocationJson(location);
|
||||
// Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||
//
|
||||
// //创建Marker对象之后,修改属性
|
||||
//// Animation animation = new AlphaAnimation(0.7f, 0f);
|
||||
//// animation.setDuration(2000);
|
||||
//// mCustomMarker.setAnimation(animation);
|
||||
//// mCustomMarker.startAnimation();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
@ -161,10 +162,10 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
// 读取数据
|
||||
locationJsonList = LocationFileStorage.loadFromFile(this);
|
||||
|
||||
for (LocationJson lj : locationJsonList) {
|
||||
tencentMap.addMarker(new MarkerOptions(toTencentLatLng(lj.toLocation())));
|
||||
//LogUtils.d("Location", "Lat: " + loc.getLatitude() + ", Lng: " + loc.getLongitude());
|
||||
}
|
||||
// for (PostionModel lj : locationJsonList) {
|
||||
// tencentMap.addMarker(new MarkerOptions(toTencentLatLng(lj.toLocation())));
|
||||
// //LogUtils.d("Location", "Lat: " + loc.getLatitude() + ", Lng: " + loc.getLongitude());
|
||||
// }
|
||||
}
|
||||
|
||||
void addLocationJson(Location location) {
|
||||
@ -176,7 +177,7 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
|
||||
// 方式1:保存到文件
|
||||
//List<Location> locations = new ArrayList<>();
|
||||
locationJsonList.add(new LocationJson(location));
|
||||
locationJsonList.add(new PostionModel(location));
|
||||
LocationFileStorage.saveToFile(this, locationJsonList);
|
||||
|
||||
// 读取数据
|
||||
@ -215,13 +216,13 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
|
||||
|
||||
// 添加标记方法
|
||||
private void addMarker(LatLng latLng) {
|
||||
tencentMap.clearAllOverlays();
|
||||
MarkerOptions options = new MarkerOptions(latLng)
|
||||
.icon(BitmapDescriptorFactory.defaultMarker())
|
||||
.title("点击保存");
|
||||
tencentMap.addMarker(options);
|
||||
}
|
||||
// private void addMarker(LatLng latLng) {
|
||||
// tencentMap.clearAllOverlays();
|
||||
// MarkerOptions options = new MarkerOptions(latLng)
|
||||
// .icon(BitmapDescriptorFactory.defaultMarker())
|
||||
// .title("点击保存");
|
||||
// tencentMap.addMarker(options);
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
@ -246,8 +247,8 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_demomain) {
|
||||
Intent intent = new Intent(this, com.tencent.map.vector.demo.DemoMainActivity.class);
|
||||
startActivity(intent);
|
||||
// Intent intent = new Intent(this, com.tencent.map.vector.demo.DemoMainActivity.class);
|
||||
// startActivity(intent);
|
||||
//WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
|
||||
} else if (item.getItemId() == R.id.item_testmapview) {
|
||||
Intent intent = new Intent(this, TestMapViewActivity.class);
|
||||
@ -431,15 +432,15 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss
|
||||
locationChangedListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "failed");
|
||||
}
|
||||
// @Override
|
||||
// public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||
// Log.e("location quest: ", "success");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||
// Log.e("location quest: ", "failed");
|
||||
// }
|
||||
|
||||
private void checkLocationPermission() {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.tencent.map.vector.demo;
|
||||
package cc.winboll.studio.positions.activities;
|
||||
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
@ -6,13 +6,9 @@ package cc.winboll.studio.positions.activities;
|
||||
*/
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.views.GridMapView;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View;
|
||||
|
||||
public class GridMapActivity extends AppCompatActivity {
|
||||
|
||||
|
@ -0,0 +1,129 @@
|
||||
package cc.winboll.studio.positions.activities;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/10 19:56:49
|
||||
* @Describe Main2Activity
|
||||
*/
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import cc.winboll.studio.positions.R;
|
||||
|
||||
public class JointPositioningActivity extends AppCompatActivity {
|
||||
|
||||
public static final String TAG = "JointPositioningActivity";
|
||||
|
||||
|
||||
private LocationManager locationManager;
|
||||
private TextView locationTextView;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main2);
|
||||
|
||||
locationTextView = findViewById(R.id.location_text_view);
|
||||
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
|
||||
// 检查权限
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this,
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||
1);
|
||||
return;
|
||||
}
|
||||
|
||||
// 请求GPS定位
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsLocationListener);
|
||||
|
||||
// 请求基站(网络)定位
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkLocationListener);
|
||||
}
|
||||
|
||||
private LocationListener gpsLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理GPS定位结果
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
private LocationListener networkLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理基站(网络)定位结果
|
||||
updateLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
private void updateLocation(Location location) {
|
||||
if (location != null) {
|
||||
double latitude = location.getLatitude();
|
||||
double longitude = location.getLongitude();
|
||||
|
||||
// 简单的融合示例:这里只是显示最后获取到的位置,实际应用中需要更复杂的融合算法
|
||||
locationTextView.setText("Latitude: " + latitude + ", Longitude: " + longitude);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == 1) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
// 权限已授予,可以继续获取位置信息
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsLocationListener);
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkLocationListener);
|
||||
} else {
|
||||
Toast.makeText(this, "权限被拒绝,无法获取位置信息", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (locationManager != null) {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
locationManager.removeUpdates(gpsLocationListener);
|
||||
locationManager.removeUpdates(networkLocationListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ package cc.winboll.studio.positions.activities;
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/21 05:37:42
|
||||
*/
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@ -14,14 +15,13 @@ import android.provider.Settings;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
import android.widget.Toolbar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.libappbase.winboll.IWinBollActivity;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import java.lang.reflect.Field;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import cc.winboll.studio.libappbase.IWinBollActivity;
|
||||
import cc.winboll.studio.libappbase.bean.APPInfo;
|
||||
|
||||
public class SettingsActivity extends AppCompatActivity implements IWinBollActivity {
|
||||
|
||||
@ -29,36 +29,16 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv
|
||||
|
||||
Toolbar mToolbar;
|
||||
|
||||
@Override
|
||||
public APPInfo getAppInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppCompatActivity getActivity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Toolbar initToolBar() {
|
||||
return findViewById(R.id.activitymainToolbar1);
|
||||
public Activity getActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAddWinBollToolBar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableDisplayHomeAsUp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -66,13 +46,11 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv
|
||||
|
||||
// 初始化工具栏
|
||||
mToolbar = findViewById(R.id.activitymainToolbar1);
|
||||
setSupportActionBar(mToolbar);
|
||||
if (isEnableDisplayHomeAsUp()) {
|
||||
// 显示后退按钮
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
getSupportActionBar().setSubtitle(getTag());
|
||||
|
||||
setActionBar(mToolbar);
|
||||
// 显示后退按钮
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getActionBar().setSubtitle(getTag());
|
||||
|
||||
}
|
||||
|
||||
public void onDefaultPhone(View view) {
|
||||
|
@ -4,20 +4,11 @@ package cc.winboll.studio.positions.activities;
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/24 12:14:04
|
||||
*/
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.heatoverlay.ScatterPlotOverlayActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class TestMapViewActivity extends AppCompatActivity {
|
||||
|
||||
|
@ -9,29 +9,30 @@ import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import cc.winboll.studio.positions.fragments.GmsFragment;
|
||||
import cc.winboll.studio.positions.fragments.ContactsFragment;
|
||||
import cc.winboll.studio.positions.fragments.TasksFragment;
|
||||
import cc.winboll.studio.positions.fragments.PositionsFragment;
|
||||
import cc.winboll.studio.positions.fragments.LogFragment;
|
||||
|
||||
public class MyPagerAdapter extends FragmentPagerAdapter {
|
||||
public static final String TAG = "MyPagerAdapter";
|
||||
public class MyPagerAdapter2 extends FragmentPagerAdapter {
|
||||
public static final String TAG = "MyPagerAdapter2";
|
||||
|
||||
private static final int PAGE_COUNT = 3;
|
||||
|
||||
public MyPagerAdapter(@NonNull FragmentManager fm) {
|
||||
public MyPagerAdapter2(@NonNull FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
if(position == 1) {
|
||||
return ContactsFragment.newInstance(position);
|
||||
} else if(position == 2) {
|
||||
return LogFragment.newInstance(position);
|
||||
} else {
|
||||
return GmsFragment.newInstance(position);
|
||||
}
|
||||
// if(position == 0) {
|
||||
// return PositionsFragment.newInstance(position);
|
||||
// } else if(position == 1) {
|
||||
// return TasksFragment.newInstance(position);
|
||||
// } else {
|
||||
// return LogFragment.newInstance(position);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
@ -0,0 +1,250 @@
|
||||
package cc.winboll.studio.positions.adapters;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/04 13:38:13
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.dialogs.YesNoAlertDialog;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import cc.winboll.studio.positions.utils.PostionUtils;
|
||||
import cc.winboll.studio.positions.views.LeftScrollView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PostionModelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
|
||||
public static final String TAG = "PostionModelAdapter";
|
||||
|
||||
private static final int VIEW_TYPE_SIMPLE = 0;
|
||||
private static final int VIEW_TYPE_EDIT = 1;
|
||||
|
||||
private Context context;
|
||||
private ArrayList<PostionModel> mPostionList;
|
||||
|
||||
public PostionModelAdapter(Context context, ArrayList<PostionModel> postionList) {
|
||||
this.context = context;
|
||||
this.mPostionList = postionList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
if (viewType == VIEW_TYPE_SIMPLE) {
|
||||
View view = inflater.inflate(R.layout.view_position_simple, parent, false);
|
||||
return new SimpleViewHolder(parent, view);
|
||||
} else {
|
||||
View view = inflater.inflate(R.layout.view_position, parent, false);
|
||||
return new EditViewHolder(parent, view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) {
|
||||
final PostionModel model = mPostionList.get(position);
|
||||
if (holder instanceof SimpleViewHolder) {
|
||||
final SimpleViewHolder simpleViewHolder = (SimpleViewHolder) holder;
|
||||
String szView = model.getComments().trim().equals("") ?"[NULL]": model.getComments();
|
||||
simpleViewHolder.tvComments.setText(szView);
|
||||
simpleViewHolder.scrollView.setOnActionListener(new LeftScrollView.OnActionListener(){
|
||||
|
||||
@Override
|
||||
public void onUp() {
|
||||
ArrayList<PostionModel> list = mPostionList;
|
||||
if (position > 0) {
|
||||
ToastUtils.show("onUp");
|
||||
simpleViewHolder.scrollView.smoothScrollTo(0, 0);
|
||||
// PhoneConnectRuleModel newBean = new PhoneConnectRuleModel();
|
||||
// newBean.setRuleText(list.get(position).getRuleText());
|
||||
// newBean.setIsAllowConnection(list.get(position).isAllowConnection());
|
||||
// newBean.setIsEnable(list.get(position).isEnable());
|
||||
// newBean.setIsSimpleView(list.get(position).isSimpleView());
|
||||
list.add(position - 1, list.get(position));
|
||||
list.remove(position + 1);
|
||||
PostionUtils.getInstance(context).savePostionModelList();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDown() {
|
||||
ArrayList<PostionModel> list = mPostionList;
|
||||
if (position < list.size() - 1) {
|
||||
ToastUtils.show("onDown");
|
||||
simpleViewHolder.scrollView.smoothScrollTo(0, 0);
|
||||
// PhoneConnectRuleModel newBean = new PhoneConnectRuleModel();
|
||||
// newBean.setRuleText(list.get(position).getRuleText());
|
||||
// newBean.setIsAllowConnection(list.get(position).isAllowConnection());
|
||||
// newBean.setIsEnable(list.get(position).isEnable());
|
||||
// newBean.setIsSimpleView(list.get(position).isSimpleView());
|
||||
list.add(position + 2, list.get(position));
|
||||
list.remove(position);
|
||||
PostionUtils.getInstance(context).savePostionModelList();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEdit() {
|
||||
simpleViewHolder.scrollView.smoothScrollTo(0, 0);
|
||||
model.setIsSimpleView(false);
|
||||
notifyDataSetChanged();
|
||||
//notifyItemChanged(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete() {
|
||||
YesNoAlertDialog.show(simpleViewHolder.scrollView.getContext(), "删除确认", "是否删除该通话规则?", new YesNoAlertDialog.OnDialogResultListener(){
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
simpleViewHolder.scrollView.smoothScrollTo(0, 0);
|
||||
model.setIsSimpleView(true);
|
||||
ArrayList<PostionModel> list = mPostionList;
|
||||
list.remove(position);
|
||||
PostionUtils.getInstance(context).savePostionModelList();
|
||||
notifyDataSetChanged();
|
||||
//notifyItemChanged(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNo() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
// simpleViewHolder.editButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// model.setIsSimpleView(false);
|
||||
// notifyItemChanged(position);
|
||||
// }
|
||||
// });
|
||||
// simpleViewHolder.deleteButton.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// model.setIsSimpleView(false);
|
||||
// ArrayList<PhoneConnectRuleModel> list = Rules.getInstance(context).getPhoneBlacRuleBeanList();
|
||||
// list.remove(position);
|
||||
// Rules.getInstance(context).saveRules();
|
||||
// notifyItemChanged(position);
|
||||
// }
|
||||
// });
|
||||
// // 触摸事件处理
|
||||
// simpleViewHolder.contentLayout.setOnTouchListener(new View.OnTouchListener() {
|
||||
// @Override
|
||||
// public boolean onTouch(View v, MotionEvent event) {
|
||||
// switch (event.getAction()) {
|
||||
// case MotionEvent.ACTION_DOWN:
|
||||
// simpleViewHolder.startX = event.getX();
|
||||
// simpleViewHolder.isSwiping = true;
|
||||
// break;
|
||||
// case MotionEvent.ACTION_MOVE:
|
||||
// if (simpleViewHolder.isSwiping) {
|
||||
// float deltaX = simpleViewHolder.startX - event.getX();
|
||||
// if (deltaX > 0) { // 左滑
|
||||
// float translationX = Math.max(-simpleViewHolder.actionLayout.getWidth(), -deltaX);
|
||||
// simpleViewHolder.contentLayout.setTranslationX(translationX);
|
||||
// simpleViewHolder.actionLayout.setVisibility(View.VISIBLE);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case MotionEvent.ACTION_UP:
|
||||
// simpleViewHolder.isSwiping = false;
|
||||
// if (simpleViewHolder.contentLayout.getTranslationX() < -simpleViewHolder.actionLayout.getWidth() / 2) {
|
||||
// // 保持按钮显示
|
||||
// simpleViewHolder.contentLayout.setTranslationX(-actionLayout.getWidth());
|
||||
// } else {
|
||||
// // 恢复原状
|
||||
// simpleViewHolder.contentLayout.animate().translationX(0).setDuration(200).start();
|
||||
// simpleViewHolder.actionLayout.setVisibility(View.INVISIBLE);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// });
|
||||
} else if (holder instanceof EditViewHolder) {
|
||||
final EditViewHolder editViewHolder = (EditViewHolder) holder;
|
||||
editViewHolder.etComments.setText(model.getComments());
|
||||
editViewHolder.swEnable.setChecked(model.isEnable());
|
||||
editViewHolder.btnConfirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
model.setComments(editViewHolder.etComments.getText().toString());
|
||||
model.setIsEnable(editViewHolder.swEnable.isChecked());
|
||||
model.setIsSimpleView(true);
|
||||
PostionUtils.getInstance(context).savePostionModelList();
|
||||
notifyItemChanged(position);
|
||||
Toast.makeText(context, "保存成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mPostionList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
PostionModel model = mPostionList.get(position);
|
||||
// 这里可以根据模型的状态来决定视图类型,简单起见,假设点击按钮后进入编辑视图
|
||||
return model.isSimpleView() ? VIEW_TYPE_SIMPLE : VIEW_TYPE_EDIT;
|
||||
}
|
||||
|
||||
static class SimpleViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final LeftScrollView scrollView;
|
||||
private final TextView tvComments;
|
||||
|
||||
|
||||
public SimpleViewHolder(@NonNull ViewGroup parent, @NonNull View itemView) {
|
||||
super(itemView);
|
||||
//LinearLayout linearLayout = itemView.findViewById(R.id.linearLayout);
|
||||
scrollView = itemView.findViewById(R.id.scrollView);
|
||||
//tvRuleText = itemView.findViewById(R.id.ruletext_tv);
|
||||
tvComments = new TextView(itemView.getContext());
|
||||
|
||||
//tvComments.setBackgroundColor(Color.GRAY);
|
||||
//LogUtils.d(TAG, String.format("linearLayout.getMeasuredWidth() %d", linearLayout.getMeasuredWidth()));
|
||||
LogUtils.d(TAG, String.format("parent.getMeasuredWidth() %d", parent.getMeasuredWidth()));
|
||||
scrollView.setContentWidth(parent.getMeasuredWidth());
|
||||
//scrollView.setContentWidth(600);
|
||||
scrollView.addContentLayout(tvComments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class EditViewHolder extends RecyclerView.ViewHolder {
|
||||
EditText etComments;
|
||||
Switch swEnable;
|
||||
Button btnMoveCarema;
|
||||
Button btnConfirm;
|
||||
|
||||
public EditViewHolder(@NonNull ViewGroup parent, @NonNull View itemView) {
|
||||
super(itemView);
|
||||
etComments = itemView.findViewById(R.id.comments_et);
|
||||
swEnable = itemView.findViewById(R.id.enable_sw);
|
||||
btnMoveCarema = itemView.findViewById(R.id.movecarema_btn);
|
||||
btnConfirm = itemView.findViewById(R.id.confirm_btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
package cc.winboll.studio.positions.fragments;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/20 12:57:50
|
||||
* @Describe 联系人
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.positions.R;
|
||||
|
||||
public class ContactsFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "ContactsFragment";
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
|
||||
public static ContactsFragment newInstance(int page) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
ContactsFragment fragment = new ContactsFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments()!= null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_contacts, container, false);
|
||||
TextView textView = view.findViewById(R.id.page_text);
|
||||
textView.setText("这是第 " + mPage + " 页");
|
||||
return view;
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package cc.winboll.studio.positions.fragments;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/20 12:57:00
|
||||
* @Describe 拨号
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.graphics.Color;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.positions.views.GridMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
|
||||
public class GmsFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "GmsFragment";
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
private TextureMapView mapView;
|
||||
protected TencentMap tencentMap;
|
||||
|
||||
public static GmsFragment newInstance(int page) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
GmsFragment fragment = new GmsFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments()!= null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_gms, container, false);
|
||||
|
||||
// // 初始化视图
|
||||
// GridMapView mapView = (GridMapView) view.findViewById(R.id.map_view);
|
||||
//
|
||||
// // 设置网格参数
|
||||
// mapView.setGridParameters(10000f, 10000f, 10f);
|
||||
//
|
||||
// // 初始化显示区域(中心点400,300,显示范围2000x200)
|
||||
// mapView.initViewport(5000f, 5000f, 1000f, 1000f);
|
||||
//
|
||||
// // 绘制图形
|
||||
// mapView.drawPoint(5000f, 5000f, Color.RED, 8f);
|
||||
// mapView.drawCircle(5000f, 5000f, 50f, Color.BLUE, 8f);
|
||||
// mapView.drawLine(4975f, 4975f, 5025f, 5025f, Color.GREEN, 2f);
|
||||
|
||||
// 初始化地图视图
|
||||
mapView = view.findViewById(R.id.mapView);
|
||||
mapView.setOpaque(false);
|
||||
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
||||
tencentMap = mapView.getMap();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mapview的生命周期管理
|
||||
*/
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
}
|
@ -21,30 +21,40 @@ public class LogFragment extends Fragment {
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
|
||||
LogView mLogView;
|
||||
|
||||
public static LogFragment newInstance(int page) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
LogFragment fragment = new LogFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments() != null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
}
|
||||
}
|
||||
// public static LogFragment newInstance(int page) {
|
||||
// Bundle args = new Bundle();
|
||||
// args.putInt(ARG_PAGE, page);
|
||||
// LogFragment fragment = new LogFragment();
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// if (getArguments() != null) {
|
||||
// mPage = getArguments().getInt(ARG_PAGE);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_log, container, false);
|
||||
LogView logView = view.findViewById(R.id.logview);
|
||||
logView.start();
|
||||
mLogView = view.findViewById(R.id.logview);
|
||||
mLogView.start();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mLogView.start();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,508 @@
|
||||
package cc.winboll.studio.positions.fragments;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/20 12:57:50
|
||||
* @Describe 联系人
|
||||
*/
|
||||
import android.Manifest;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemClock;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.positions.MainActivity;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.adapters.PostionModelAdapter;
|
||||
import cc.winboll.studio.positions.listeners.OnGPSRTLocationListener;
|
||||
import cc.winboll.studio.positions.models.PostionFixModel;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import cc.winboll.studio.positions.services.GPSService;
|
||||
import cc.winboll.studio.positions.utils.LocationFusion;
|
||||
import cc.winboll.studio.positions.utils.PostionUtils;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PositionsFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "PositionsFragment";
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
|
||||
private LocationManager locationManager;
|
||||
|
||||
|
||||
//MyHandler mMyHandler;
|
||||
|
||||
TextView mtvTXMyLocationInfo;
|
||||
TextView mtvPhoneGPSInfo;
|
||||
MyServiceConnection mMyServiceConnection;
|
||||
GPSService mGPSService;
|
||||
Button mbtnTXRT;
|
||||
Button mbtnAdd;
|
||||
Location mLocationTX;
|
||||
Location mLocationPhoneGPS;
|
||||
private RecyclerView recyclerView;
|
||||
private PostionModelAdapter mPostionModelAdapter;
|
||||
private ArrayList<PostionModel> mPostionList;
|
||||
|
||||
TextView mtvPostionFixModelInfo;
|
||||
TextView mtvLockPostionInfo;
|
||||
|
||||
EditText metLockLatitude;
|
||||
EditText metLockLongitude;
|
||||
|
||||
Switch mswTaskService;
|
||||
|
||||
double latitudeWifiLock;
|
||||
double longitudeWifiLock;
|
||||
double latitudeGPSLock;
|
||||
double longitudeGPSLock;
|
||||
double latitudeFuseLock;
|
||||
double longitudeFuseLock;
|
||||
|
||||
PostionFixModel mPostionFixModel;
|
||||
static Location _LocationPhoneGPSLock;
|
||||
|
||||
LocationManager locationManagerPhoneGPS;
|
||||
volatile static int nFixActivationCountValue = 70;
|
||||
volatile static int nCurrentFixActivationCountValue = 0;
|
||||
volatile static int nGPSUpdateCount = 0;
|
||||
|
||||
// public static PositionsFragment newInstance(int page) {
|
||||
// Bundle args = new Bundle();
|
||||
// args.putInt(ARG_PAGE, page);
|
||||
// PositionsFragment fragment = new PositionsFragment();
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// if (getArguments()!= null) {
|
||||
// mPage = getArguments().getInt(ARG_PAGE);
|
||||
// }
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View viewMain = inflater.inflate(R.layout.fragment_positions, container, false);
|
||||
|
||||
mtvTXMyLocationInfo = viewMain.findViewById(R.id.txmylocationinfo_tv);
|
||||
mtvPhoneGPSInfo = viewMain.findViewById(R.id.phonegpsinfo_tv);
|
||||
mMyServiceConnection = new MyServiceConnection();
|
||||
|
||||
Intent intent = new Intent(getActivity(), GPSService.class);
|
||||
getActivity().startService(intent);
|
||||
getActivity().bindService(intent, mMyServiceConnection, Context.BIND_IMPORTANT);
|
||||
|
||||
mbtnTXRT = viewMain.findViewById(R.id.txrt_btn);
|
||||
mbtnTXRT.setOnClickListener(new Button.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//ToastUtils.show("mbtnTXRT");
|
||||
((MainActivity)getActivity()).startTXRTLocation();
|
||||
}
|
||||
});
|
||||
mbtnAdd = viewMain.findViewById(R.id.add_btn);
|
||||
mbtnAdd.setOnClickListener(new Button.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//ToastUtils.show("mbtnAdd");
|
||||
PostionUtils postionUtils = PostionUtils.getInstance(getActivity());
|
||||
postionUtils.addPostion(mLocationPhoneGPS);
|
||||
mPostionModelAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView = viewMain.findViewById(R.id.recycler_view);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
|
||||
mPostionList = PostionUtils.getInstance(getActivity()).getPostionModelList();
|
||||
|
||||
mPostionModelAdapter = new PostionModelAdapter(getActivity(), mPostionList);
|
||||
recyclerView.setAdapter(mPostionModelAdapter);
|
||||
|
||||
|
||||
// metLockLatitude = viewMain.findViewById(R.id.locklatitude_et);
|
||||
// metLockLongitude = viewMain.findViewById(R.id.locklongitude_et);
|
||||
// metLockLatitude.setEnabled(false);
|
||||
// metLockLongitude.setEnabled(false);
|
||||
// mswTaskService = viewMain.findViewById(R.id.taskservice_sw);
|
||||
|
||||
//mMyHandler = new MyHandler();
|
||||
|
||||
//nCurrentFixActivationCountValue = 0;
|
||||
//nGPSUpdateCount = 0;
|
||||
|
||||
|
||||
// mtvPostionFixModelInfo = viewMain.findViewById(R.id.postionfixmodelinfo_tv);
|
||||
// mtvLockPostionInfo = viewMain.findViewById(R.id.lockpostioninfo_tv);
|
||||
//
|
||||
|
||||
//locationManager = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
|
||||
|
||||
// mswTaskService.setOnClickListener(new View.OnClickListener(){
|
||||
// @Override
|
||||
// public void onClick(View p1) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
// 请求GPS定位
|
||||
//locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, phoneGPSLocationListener);
|
||||
|
||||
// 请求基站(网络)定位
|
||||
//locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkLocationListener);
|
||||
|
||||
|
||||
//ToastUtils.show("PositionsFragment onCreateView");
|
||||
|
||||
//showLocationTX();
|
||||
//showLocationPhoneGPS();
|
||||
//showPostionFixModelInfo();
|
||||
|
||||
return viewMain;
|
||||
}
|
||||
|
||||
void moveToCurrentLocation() {
|
||||
if (!metLockLatitude.getText().toString().trim().equals("")
|
||||
&& !metLockLongitude.getText().toString().trim().equals("")) {
|
||||
_LocationPhoneGPSLock = new Location("User_Defined_GPS");
|
||||
_LocationPhoneGPSLock.setLatitude(Double.parseDouble(metLockLatitude.getText().toString()));
|
||||
_LocationPhoneGPSLock.setLongitude(Double.parseDouble(metLockLongitude.getText().toString()));
|
||||
//ToastUtils.show("定位手动设定位置");
|
||||
} else {
|
||||
//Location locationFix = fixGPSLocationFromPostionFixModel(_LocationPhoneGPS);
|
||||
//_LocationPhoneGPSLock = _LocationTX;
|
||||
//_LocationPhoneGPSLock = locationFix;
|
||||
//ToastUtils.show("定位GPS设定位置");
|
||||
}
|
||||
//showLockPostionInfo();
|
||||
//ToastUtils.show(String.format("%s", locationFix.toString()));
|
||||
|
||||
TXMSFragment.moveToLocation(_LocationPhoneGPSLock.getLatitude(), _LocationPhoneGPSLock.getLongitude());
|
||||
}
|
||||
|
||||
// void showLocationPhoneGPS(Location location) {
|
||||
// if (location != null) {
|
||||
// mLocationPhoneGPS = location;
|
||||
// String szTemp = String.format("\n(%d)PhoneGPS MyLocation Info\nLatitude %f\nLongitude %f\nAccuracy %f\n", nGPSUpdateCount, _LocationPhoneGPS.getLatitude(), _LocationPhoneGPS.getLongitude(), _LocationPhoneGPS.getAccuracy());
|
||||
// mtvPhoneMyLocationInfo.append(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void showPostionFixModelInfo() {
|
||||
// if (mPostionFixModel != null && mLocationTX != null && _LocationPhoneGPS != null) {
|
||||
// String szTemp = String.format("\n(%d)FixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\n\n",
|
||||
// nCurrentFixActivationCountValue,
|
||||
// mLocationTX.getLatitude(),
|
||||
// _LocationPhoneGPS.getLatitude(),
|
||||
// mPostionFixModel.getLatitudeFixModel(),
|
||||
// mLocationTX.getLongitude(),
|
||||
// _LocationPhoneGPS.getLongitude(),
|
||||
// mPostionFixModel.getLongitudeFixModel());
|
||||
// mtvPostionFixModelInfo.append(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void showLockPostionInfo() {
|
||||
// if (mPostionFixModel != null && mLocationTX != null && _LocationPhoneGPSLock != null) {
|
||||
// String szTemp = String.format("\n%s\nFixModel Info\nLatitude TX %f\nLatitude GPS %f\nLatitude Fix %f\nLatitude GPSLock %f\nLongitude TX %f\nLongitude GPS %f\nLongitude Fix %f\nLongitude GPSLock %f\n\n",
|
||||
// TimeUtils.getCurrentTimeString(),
|
||||
// mLocationTX.getLatitude(),
|
||||
// _LocationPhoneGPS.getLatitude(),
|
||||
// mPostionFixModel.getLatitudeFixModel(),
|
||||
// _LocationPhoneGPSLock.getLatitude(),
|
||||
// mLocationTX.getLongitude(),
|
||||
// _LocationPhoneGPS.getLongitude(),
|
||||
// mPostionFixModel.getLongitudeFixModel(),
|
||||
// _LocationPhoneGPSLock.getLongitude());
|
||||
// mtvLockPostionInfo.append(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// }
|
||||
// }
|
||||
|
||||
// void showLocationTX() {
|
||||
// if (_LocationTX != null) {
|
||||
// String szTemp = String.format("TX MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", _LocationTX.getLatitude(), _LocationTX.getLongitude(), _LocationTX.getAccuracy());
|
||||
// mtvTXMyLocationInfo.setText(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// }
|
||||
// }
|
||||
|
||||
public void showLocationTX(Location location) {
|
||||
if (location != null) {
|
||||
mLocationTX = location;
|
||||
String szTemp = String.format("TX MyLocation Info\nLatitude %f, Longitude %f\nAccuracy %f", mLocationTX.getLatitude(), mLocationTX.getLongitude(), mLocationTX.getAccuracy());
|
||||
mtvTXMyLocationInfo.setText(szTemp);
|
||||
LogUtils.d(TAG, szTemp);
|
||||
}
|
||||
}
|
||||
|
||||
public void showLocationPhoneGPS(Location location) {
|
||||
if (location != null) {
|
||||
mLocationPhoneGPS = location;
|
||||
String szTemp = String.format("Phone GPS Info\nLatitude %f, Longitude %f\nAccuracy %f", mLocationPhoneGPS.getLatitude(), mLocationPhoneGPS.getLongitude(), mLocationPhoneGPS.getAccuracy());
|
||||
mtvPhoneGPSInfo.setText(szTemp);
|
||||
LogUtils.d(TAG, szTemp);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.toolbar_positions, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (locationManager != null) {
|
||||
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
locationManager.removeUpdates(phoneGPSLocationListener);
|
||||
locationManager.removeUpdates(networkLocationListener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// if (item.getItemId() == R.id.item_addposition) {
|
||||
// ToastUtils.show("item_addposition");
|
||||
// }
|
||||
// } else
|
||||
// if (item.getItemId() == R.id.item_exit) {
|
||||
// exit();
|
||||
// return true;
|
||||
// }
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
// void updatePostionFixModel() {
|
||||
// if (_LocationPhoneGPS == null
|
||||
// || mLocationTX == null) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// nCurrentFixActivationCountValue++;
|
||||
// if (nCurrentFixActivationCountValue < nFixActivationCountValue) {
|
||||
// mPostionFixModel = PostionFixModel.loadPostionFixModel();
|
||||
// mPostionFixModel.setLatitudeFixModel(_LocationPhoneGPS.getLatitude() - mLocationTX.getLatitude());
|
||||
// mPostionFixModel.setLongitudeFixModel(_LocationPhoneGPS.getLongitude() - mLocationTX.getLongitude());
|
||||
//
|
||||
//// String szTemp = String.format("PostionFixModel Info\nLatitude Fix %f, Longitude Fix %f", mPostionFixModel.getLatitudeFixModel(), mPostionFixModel.getLongitudeFixModel());
|
||||
//// mtvPostionFixModelInfo.setText(szTemp);
|
||||
//// LogUtils.d(TAG, szTemp);
|
||||
// PostionFixModel.savePostionFixModel(mPostionFixModel);
|
||||
// //ToastUtils.show(szTemp);
|
||||
// LogUtils.d(TAG, String.format("updatePostionFixModel() run %d", nCurrentFixActivationCountValue));
|
||||
//
|
||||
// showPostionFixModelInfo();
|
||||
// } else {
|
||||
// // 定位修复模型数据定型, GPS定位监听停止
|
||||
// // 在需要停止监听的地方(如onPause/onDestroy)添加:
|
||||
// if (locationManagerPhoneGPS != null) {
|
||||
// // 取消位置更新监听
|
||||
// locationManagerPhoneGPS.removeUpdates(phoneGPSLocationListener);
|
||||
// // 可选:停止后释放资源
|
||||
// phoneGPSLocationListener = null;
|
||||
// }
|
||||
// LogUtils.d(TAG, String.format("updatePostionFixModel() stop %d", nCurrentFixActivationCountValue));
|
||||
// }
|
||||
// }
|
||||
|
||||
private Location fixGPSLocationFromPostionFixModel(Location location) {
|
||||
// 用腾讯定位数据与GPS定位数据的数据差修复模型,来修复一下GPS定位数据。
|
||||
mPostionFixModel = PostionFixModel.loadPostionFixModel();
|
||||
|
||||
//Location location = locationTX;
|
||||
Location locationFix = new Location("GPS_Fix_Map_Manual");
|
||||
|
||||
// 设置基础坐标
|
||||
locationFix.setLatitude(location.getLatitude() - mPostionFixModel.getLatitudeFixModel());
|
||||
locationFix.setLongitude(location.getLongitude() - mPostionFixModel.getLongitudeFixModel());
|
||||
|
||||
// 设置必要元数据
|
||||
locationFix.setTime(System.currentTimeMillis());
|
||||
locationFix.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
locationFix.setAccuracy(5.0f); // 手动点击精度设为5米
|
||||
|
||||
return locationFix;
|
||||
}
|
||||
|
||||
private LocationListener phoneGPSLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理GPS定位结果
|
||||
nGPSUpdateCount++;
|
||||
updateGPSLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
private LocationListener networkLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理基站(网络)定位结果
|
||||
updateWifiLocation(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
void updateWifiLocation(Location location) {
|
||||
if (location != null) {
|
||||
double latitude = location.getLatitude();
|
||||
double longitude = location.getLongitude();
|
||||
|
||||
latitudeWifiLock = latitude;
|
||||
longitudeWifiLock = longitude;
|
||||
|
||||
// 简单的融合示例:这里只是显示最后获取到的位置,实际应用中需要更复杂的融合算法
|
||||
//tvWifiLocation.setText(String.format("Wifi [ Latitude: %f \nLongitude: %f ]", latitudeWifiLock, longitudeWifiLock));
|
||||
fuseLocationData();
|
||||
}
|
||||
}
|
||||
|
||||
void updateGPSLocation(Location location) {
|
||||
if (location != null) {
|
||||
// double latitude = location.getLatitude();
|
||||
// double longitude = location.getLongitude();
|
||||
//
|
||||
// latitudeGPSLock = latitude;
|
||||
// longitudeGPSLock = longitude;
|
||||
//
|
||||
// // 简单的融合示例:这里只是显示最后获取到的位置,实际应用中需要更复杂的融合算法
|
||||
// tvGPSLocation.setText(String.format("GPS [ Latitude: %f \nLongitude: %f ]", latitudeGPSLock, longitudeGPSLock));
|
||||
// fuseLocationData();
|
||||
|
||||
//_LocationPhoneGPS = location;
|
||||
// 位置变化时的处理逻辑
|
||||
// double latitude = location.getLatitude();
|
||||
// double longitude = location.getLongitude();
|
||||
// String szTemp = String.format("Phone GPS MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", _LocationPhoneGPS.getLatitude(), _LocationPhoneGPS.getLongitude(), _LocationPhoneGPS.getAccuracy());
|
||||
// mtvPhoneMyLocationInfo.setText(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
//showLocationPhoneGPS();
|
||||
//updatePostionFixModel();
|
||||
if(mswTaskService.isChecked()) {
|
||||
moveToCurrentLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fuseLocationData() {
|
||||
// 融合数据不充分退出
|
||||
if (latitudeWifiLock == 0 ||
|
||||
longitudeWifiLock == 0 ||
|
||||
latitudeGPSLock == 0 ||
|
||||
longitudeGPSLock == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
double[] result = LocationFusion.fuseLocationData(latitudeGPSLock, longitudeGPSLock,
|
||||
latitudeWifiLock, longitudeWifiLock,
|
||||
0.6, 0.4);
|
||||
latitudeFuseLock = result[0];
|
||||
longitudeFuseLock = result[1];
|
||||
|
||||
//tvFuseLocation.setText(String.format("Fuse [ Latitude: %f \nLongitude: %f ]", latitudeFuseLock, longitudeFuseLock));
|
||||
}
|
||||
|
||||
// public static final int INIT_POSITION = 1;
|
||||
// class MyHandler extends Handler {
|
||||
// @Override
|
||||
// public void handleMessage(@NonNull Message msg) {
|
||||
// switch (msg.what) {
|
||||
// case INIT_POSITION:
|
||||
// // 在这里处理接收到消息后的逻辑,比如更新 UI
|
||||
// mLocationTX = (Location)msg.obj;
|
||||
// //showLocationTX();
|
||||
//
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
// public void sendInitPositioningMessage(Location location) {
|
||||
// if (mMyHandler != null) {
|
||||
// Message message = Message.obtain();
|
||||
// message.what = INIT_POSITION;
|
||||
// message.obj = location;
|
||||
// mMyHandler.sendMessage(message);
|
||||
// }
|
||||
// }
|
||||
|
||||
private class MyServiceConnection implements ServiceConnection {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
LogUtils.d(TAG, "onServiceConnected(...)");
|
||||
GPSService.MyBinder binder = (GPSService.MyBinder) service;
|
||||
mGPSService = binder.getService();
|
||||
mGPSService.setOnGPSRTLocationListener(new OnGPSRTLocationListener(){
|
||||
@Override
|
||||
public void onGPSRTLocation(Location location) {
|
||||
showLocationPhoneGPS(location);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
LogUtils.d(TAG, "onServiceDisconnected(...)");
|
||||
mGPSService = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -6,33 +6,33 @@ package cc.winboll.studio.positions.fragments;
|
||||
* @Describe 腾讯地图服务视图
|
||||
*/
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.positions.activities.SettingsActivity;
|
||||
import cc.winboll.studio.positions.activities.TestMapViewActivity;
|
||||
import cc.winboll.studio.positions.listeners.OnTXRTLocationListener;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import cc.winboll.studio.positions.utils.LocationFileStorage;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentLocationListener;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
@ -43,6 +43,7 @@ import com.tencent.tencentmap.mapsdk.maps.LocationSource;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
@ -51,174 +52,174 @@ import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
import cc.winboll.studio.positions.beans.LocationJson;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.libappbase.LogView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.NonNull;
|
||||
import android.graphics.Color;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.positions.views.GridMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
|
||||
public class TXMSFragment extends Fragment implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener {
|
||||
|
||||
public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener,TencentMap.OnMapClickListener {
|
||||
|
||||
public static final String TAG = "TXMSFragment";
|
||||
|
||||
|
||||
|
||||
private static final int PERMISSION_REQUEST_CODE = 1;
|
||||
|
||||
private LocationManager mLocationManager;
|
||||
private LocationListener mLocationListener;
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
private TextureMapView mapView;
|
||||
protected TencentMap tencentMap;
|
||||
TextView mtvInfo;
|
||||
|
||||
private LocationSource.OnLocationChangedListener locationChangedListener;
|
||||
|
||||
private TencentLocationManager locationManager;
|
||||
private TencentLocationRequest locationRequest;
|
||||
private MyLocationStyle locationStyle;
|
||||
ArrayList<LocationJson> locationJsonList;
|
||||
|
||||
public static TXMSFragment newInstance(int page) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ARG_PAGE, page);
|
||||
TXMSFragment fragment = new GmsFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (getArguments()!= null) {
|
||||
mPage = getArguments().getInt(ARG_PAGE);
|
||||
}
|
||||
}
|
||||
private TencentLocationManager mTencentLocationManager;
|
||||
private TencentLocationRequest mTencentLocationRequest;
|
||||
private MyLocationStyle mMyLocationStyle;
|
||||
ArrayList<PostionModel> locationPostionModelList;
|
||||
//Location lastLocation;
|
||||
static TXMSFragment _TXMSFragment;
|
||||
OnTXRTLocationListener mOnTXRTLocationListener;
|
||||
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View viewRoot = inflater.inflate(R.layout.fragment_gms, container, false);
|
||||
locationJsonList = new ArrayList<LocationJson>();
|
||||
_TXMSFragment = TXMSFragment.this;
|
||||
View viewRoot = inflater.inflate(R.layout.fragment_txms, container, false);
|
||||
locationPostionModelList = new ArrayList<PostionModel>();
|
||||
|
||||
mLogView = viewRoot.findViewById(R.id.logview);
|
||||
mLogView.start();
|
||||
|
||||
TencentMapInitializer.setAgreePrivacy(this, true);
|
||||
TencentMapInitializer.start(this);
|
||||
TencentMapInitializer.setAgreePrivacy(true);
|
||||
//TencentMapInitializer.setAgreePrivacy(getActivity(), true);
|
||||
//TencentMapInitializer.start(getActivity());
|
||||
TencentLocationManager.setUserAgreePrivacy(true);
|
||||
|
||||
|
||||
mapView = viewRoot.findViewById(R.id.mapview);
|
||||
mapView.setOpaque(false);
|
||||
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
||||
tencentMap = mapView.getMap();
|
||||
|
||||
FloatingActionButton fab = viewRoot.findViewById(R.id.fab);
|
||||
fab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Snackbar.make(view, "点击了悬浮按钮", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
mtvInfo = viewRoot.findViewById(R.id.tv_info);
|
||||
|
||||
checkLocationPermission();
|
||||
|
||||
//设置显示定位的图标
|
||||
TencentLocationManager.setUserAgreePrivacy(true);
|
||||
//建立定位
|
||||
//initLocation();
|
||||
//对地图操作类进行操作
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(22.984066, 116.307548),
|
||||
15,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
|
||||
// 设置地图点击监听
|
||||
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener(){
|
||||
tencentMap.setOnMapClickListener(this);
|
||||
|
||||
@Override
|
||||
public void onMapClick(com.tencent.tencentmap.mapsdk.maps.model.LatLng latLng) {
|
||||
//创建Marker对象之前,设置属性
|
||||
//LatLng position = new LatLng(40.011313,116.391907);
|
||||
BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
||||
Location location = createLocationFromLatLng(latLng);
|
||||
addLocationJson(location);
|
||||
Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||
loadLocations();
|
||||
|
||||
//创建Marker对象之后,修改属性
|
||||
UiSettings uiSettings = tencentMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(true);
|
||||
mTencentLocationManager = TencentLocationManager.getInstance(getActivity());
|
||||
//创建定位请求
|
||||
mTencentLocationRequest = TencentLocationRequest.create();
|
||||
//mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
||||
//地图上设置定位数据源
|
||||
tencentMap.setLocationSource(this);
|
||||
//设置当前位置可见
|
||||
tencentMap.setMyLocationEnabled(true);
|
||||
//设置定位图标样式
|
||||
setMyLocationMarkerStyle();
|
||||
startRTLocation();
|
||||
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
//创建Marker对象之前,设置属性
|
||||
//LatLng position = new LatLng(40.011313,116.391907);
|
||||
BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker);
|
||||
Location location = createTXLocationFromLatLng(latLng);
|
||||
addLocationToMap(location);
|
||||
Marker mCustomMarker = tencentMap.addMarker(new MarkerOptions(latLng));
|
||||
|
||||
//创建Marker对象之后,修改属性
|
||||
// Animation animation = new AlphaAnimation(0.7f, 0f);
|
||||
// animation.setDuration(2000);
|
||||
// mCustomMarker.setAnimation(animation);
|
||||
// mCustomMarker.startAnimation();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
void loadLocations() {
|
||||
// 存储位置数据
|
||||
// Location location = new Location("gps");
|
||||
// location.setLatitude(22.984066);
|
||||
// location.setLongitude(116.307548);
|
||||
// location.setTime(System.currentTimeMillis());
|
||||
//
|
||||
// // 方式1:保存到文件
|
||||
// List<Location> locations = new ArrayList<>();
|
||||
// locations.add(location);
|
||||
// LocationFileStorage.saveToFile(this, locations);
|
||||
|
||||
// 读取数据
|
||||
locationJsonList = LocationFileStorage.loadFromFile(this);
|
||||
void genLocationFixModel() {
|
||||
|
||||
for (LocationJson lj : locationJsonList) {
|
||||
tencentMap.addMarker(new MarkerOptions(toTencentLatLng(lj.toLocation())));
|
||||
//LogUtils.d("Location", "Lat: " + loc.getLatitude() + ", Lng: " + loc.getLongitude());
|
||||
}
|
||||
|
||||
public void startRTLocation() {
|
||||
//ToastUtils.show("startRTLocation()");
|
||||
mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this);
|
||||
}
|
||||
|
||||
private void stopLocation() {
|
||||
if (mTencentLocationManager != null) {
|
||||
mTencentLocationManager.removeUpdates(this);
|
||||
//mTencentLocationManager.removeLocationListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
void addLocationJson(Location location) {
|
||||
// 存储位置数据
|
||||
// Location location = new Location("gps");
|
||||
// location.setLatitude(22.984066);
|
||||
// location.setLongitude(116.307548);
|
||||
// location.setTime(System.currentTimeMillis());
|
||||
|
||||
// 方式1:保存到文件
|
||||
//List<Location> locations = new ArrayList<>();
|
||||
locationJsonList.add(new LocationJson(location));
|
||||
LocationFileStorage.saveToFile(this, locationJsonList);
|
||||
|
||||
void loadLocations() {
|
||||
// 读取数据
|
||||
// List<Location> loaded = LocationFileStorage.loadFromFile(this);
|
||||
// for (Location loc : loaded) {
|
||||
// tencentMap.addMarker(new MarkerOptions(toTencentLatLng(loc)));
|
||||
// //LogUtils.d("Location", "Lat: " + loc.getLatitude() + ", Lng: " + loc.getLongitude());
|
||||
// }
|
||||
locationPostionModelList = LocationFileStorage.loadFromFile(getActivity());
|
||||
|
||||
for (PostionModel lj : locationPostionModelList) {
|
||||
tencentMap.addMarker(new MarkerOptions(convertLocationToLatLng(lj.toLocation())));
|
||||
}
|
||||
}
|
||||
|
||||
void addLocationToMap(Location location) {
|
||||
locationPostionModelList.add(new PostionModel(location));
|
||||
LocationFileStorage.saveToFile(getActivity(), locationPostionModelList);
|
||||
}
|
||||
|
||||
// public void addCurrentLocationToMap() {
|
||||
// ToastUtils.show("addCurrentLocationToMap");
|
||||
// Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||
// locationPostionModelList.add(new PostionModel(getCurrentGPSLocation()));
|
||||
// LocationFileStorage.saveToFile(getActivity(), locationPostionModelList);
|
||||
// }
|
||||
|
||||
// 手机 GPS 定位信息
|
||||
// LocationListener phoneGPSLocationListener = new LocationListener() {
|
||||
// @Override
|
||||
// public void onLocationChanged(Location location) {
|
||||
// locationPhoneGPS = location;
|
||||
// // 位置变化时的处理逻辑
|
||||
//// double latitude = location.getLatitude();
|
||||
//// double longitude = location.getLongitude();
|
||||
// String szTemp = String.format("Phone GPS MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", locationPhoneGPS.getLatitude(), locationPhoneGPS.getLongitude(), locationPhoneGPS.getAccuracy());
|
||||
// mtvPhoneMyLocationInfo.setText(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// updatePostionFixModel();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onProviderDisabled(String provider) {}
|
||||
//
|
||||
// @Override
|
||||
// public void onProviderEnabled(String provider) {}
|
||||
//
|
||||
// @Override
|
||||
// public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
// };
|
||||
|
||||
|
||||
// 创建Location对象方法
|
||||
private Location createLocationFromLatLng(LatLng latLng) {
|
||||
Location location = new Location("tencent_map_manual");
|
||||
|
||||
|
||||
// 创建Location对象方法
|
||||
private Location createTXLocationFromLatLng(double latitudeLock, double longitudeLock) {
|
||||
Location location = new Location("Tencent_Map_Manual");
|
||||
|
||||
// 设置基础坐标
|
||||
location.setLatitude(latitudeLock);
|
||||
location.setLongitude(longitudeLock);
|
||||
|
||||
// 设置必要元数据
|
||||
location.setTime(System.currentTimeMillis());
|
||||
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
location.setAccuracy(5.0f); // 手动点击精度设为5米
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
// 创建Location对象方法
|
||||
private Location createTXLocationFromLatLng(LatLng latLng) {
|
||||
Location location = new Location("Tencent_Map_Manual");
|
||||
|
||||
// 设置基础坐标
|
||||
location.setLatitude(latLng.getLatitude());
|
||||
@ -232,15 +233,22 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LatLng convertTencentLocationToLatLng(TencentLocation location) {
|
||||
if (location != null) {
|
||||
double latitude = location.getLatitude();
|
||||
double longitude = location.getLongitude();
|
||||
return new LatLng(latitude, longitude);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LatLng toTencentLatLng(Location location) {
|
||||
public static LatLng convertLocationToLatLng(Location location) {
|
||||
return new LatLng(
|
||||
location.getLatitude(),
|
||||
location.getLongitude()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 添加标记方法
|
||||
private void addMarker(LatLng latLng) {
|
||||
tencentMap.clearAllOverlays();
|
||||
@ -250,6 +258,21 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
tencentMap.addMarker(options);
|
||||
}
|
||||
|
||||
public static final int REALTIME_POSITIONING = 1;
|
||||
private Handler handler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(@NonNull Message msg) {
|
||||
switch (msg.what) {
|
||||
case REALTIME_POSITIONING:
|
||||
// 在这里处理接收到消息后的逻辑,比如更新 UI
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* mapview的生命周期管理
|
||||
*/
|
||||
@ -282,37 +305,23 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPostCreate(Bundle savedInstanceState) {
|
||||
super.onPostCreate(savedInstanceState);
|
||||
// LatLng center = new LatLng(39.904556, 116.427242);
|
||||
// tencentMap.moveCamera(
|
||||
// CameraUpdateFactory.newLatLngZoom(center, 13f) // 注意 13 → 13f
|
||||
// );
|
||||
loadLocations();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置定位图标样式
|
||||
*/
|
||||
private void setLocMarkerStyle() {
|
||||
locationStyle = new MyLocationStyle();
|
||||
private void setMyLocationMarkerStyle() {
|
||||
mMyLocationStyle = new MyLocationStyle();
|
||||
//创建图标
|
||||
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker));
|
||||
locationStyle.icon(bitmapDescriptor);
|
||||
//BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker));
|
||||
//mMyLocationStyle.icon(bitmapDescriptor);
|
||||
//设置定位圆形区域的边框宽度
|
||||
locationStyle.strokeWidth(3);
|
||||
mMyLocationStyle.strokeWidth(0);
|
||||
//设置圆区域的颜色
|
||||
locationStyle.fillColor(R.color.style);
|
||||
mMyLocationStyle.fillColor(R.color.style);
|
||||
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
tencentMap.setMyLocationStyle(mMyLocationStyle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Bitmap getBitMap(int resourceId) {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
|
||||
int width = bitmap.getWidth();
|
||||
@ -327,30 +336,40 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 定位的一些初始化设置
|
||||
*/
|
||||
private void initLocation() {
|
||||
//用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
|
||||
locationManager = TencentLocationManager.getInstance(this);
|
||||
//设置坐标系
|
||||
locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
|
||||
//创建定位请求
|
||||
locationRequest = TencentLocationRequest.create();
|
||||
//设置定位周期(位置监听器回调周期)为3s
|
||||
locationRequest.setInterval(3000);
|
||||
|
||||
//地图上设置定位数据源
|
||||
tencentMap.setLocationSource(this);
|
||||
//设置当前位置可见
|
||||
tencentMap.setMyLocationEnabled(true);
|
||||
//设置定位图标样式
|
||||
setLocMarkerStyle();
|
||||
// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
public static void moveToLocation(double latitudeLock, double longitudeLock) {
|
||||
if (_TXMSFragment != null) {
|
||||
Location location = _TXMSFragment.createTXLocationFromLatLng(latitudeLock, longitudeLock);
|
||||
_TXMSFragment.moveToGPSLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void moveToGPSLocation(Location location) {
|
||||
//对地图操作类进行操作
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
convertLocationToLatLng(location),
|
||||
19f,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
ToastUtils.show("Move To Location.");
|
||||
//addLocationToMap(location);
|
||||
}
|
||||
|
||||
public void sendRealTimePositioningMessage() {
|
||||
Message message = Message.obtain();
|
||||
message.what = TXMSFragment.REALTIME_POSITIONING;
|
||||
handler.sendMessage(message);
|
||||
}
|
||||
|
||||
public void setOnTXRTLocationListener(OnTXRTLocationListener listener) {
|
||||
mOnTXRTLocationListener = listener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实现位置监听
|
||||
* @param tencentLocation
|
||||
@ -361,29 +380,73 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
||||
|
||||
if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
|
||||
final Location location = new Location(tencentLocation.getProvider());
|
||||
final Location locationTX = new Location(tencentLocation.getProvider());
|
||||
//设置经纬度以及精度
|
||||
location.setLatitude(tencentLocation.getLatitude());
|
||||
location.setLongitude(tencentLocation.getLongitude());
|
||||
location.setAccuracy(tencentLocation.getAccuracy());
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
locationTX.setLatitude(tencentLocation.getLatitude());
|
||||
locationTX.setLongitude(tencentLocation.getLongitude());
|
||||
locationTX.setAccuracy(tencentLocation.getAccuracy());
|
||||
|
||||
locationChangedListener.onLocationChanged(locationTX);
|
||||
moveToGPSLocation(locationTX);
|
||||
|
||||
//显示回调的实时位置信息
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Rules.getEffectInfo(location);
|
||||
// double distance = DistanceUtils.getDistance(
|
||||
// locationA.getLatitude(),
|
||||
// locationA.getLongitude(),
|
||||
// locationB.getLatitude(),
|
||||
// locationB.getLongitude()
|
||||
// );
|
||||
mtvInfo.setText(String.format("\n%f %f", location.getLatitude(), location.getLongitude()));
|
||||
//打印tencentLocation的json字符串
|
||||
// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
// getActivity().runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
//
|
||||
// //对地图操作类进行操作
|
||||
//// CameraUpdate cameraSigma =
|
||||
//// CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
//// convertToLatLng(location),
|
||||
//// 15,
|
||||
//// 0f,
|
||||
//// 0f));
|
||||
//// //移动地图
|
||||
//// tencentMap.moveCamera(cameraSigma);
|
||||
//// Rules.getEffectInfo(location);
|
||||
//// double distance = DistanceUtils.getDistance(
|
||||
//// locationA.getLatitude(),
|
||||
//// locationA.getLongitude(),
|
||||
//// locationB.getLatitude(),
|
||||
//// locationB.getLongitude()
|
||||
//// );
|
||||
// String szTemp = String.format("TX MyLocation Init Info\nLatitude %f, Longitude %f, Accuracy %f", locationTX.getLatitude(), locationTX.getLongitude(), locationTX.getAccuracy());
|
||||
// mtvTXMyLocationInfo.setText(szTemp);
|
||||
// LogUtils.d(TAG, szTemp);
|
||||
// //打印tencentLocation的json字符串
|
||||
//// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
||||
//
|
||||
//
|
||||
// //
|
||||
// // 本机 GPS 定位服务调用服务
|
||||
// //
|
||||
// locationManagerPhoneGPS = (LocationManager) getActivity().getSystemService(getActivity().LOCATION_SERVICE);
|
||||
// String provider = LocationManager.GPS_PROVIDER;
|
||||
// //Location location = locationManager.getLastKnownLocation(provider);
|
||||
// locationManagerPhoneGPS.requestLocationUpdates(provider, 2000, 10, phoneGPSLocationListener);
|
||||
// }
|
||||
// });
|
||||
|
||||
// 保存最后定位信息
|
||||
// lastLocation = new Location(tencentLocation.getProvider());
|
||||
// lastLocation.setLatitude(tencentLocation.getLatitude());
|
||||
// lastLocation.setLongitude(tencentLocation.getLongitude());
|
||||
// lastLocation.setAccuracy(tencentLocation.getAccuracy());
|
||||
|
||||
//PositionsFragment.sendInitPositioningMessage(locationTX);
|
||||
mOnTXRTLocationListener.onTXRTLocation(locationTX);
|
||||
|
||||
// 当不再需要定位时
|
||||
// 取消定位监听
|
||||
if (mTencentLocationManager != null) {
|
||||
mTencentLocationManager.removeUpdates(this);
|
||||
}
|
||||
// 关闭当前位置显示
|
||||
// if (tencentMap != null) {
|
||||
// tencentMap.setMyLocationEnabled(false);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,16 +461,16 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
public void activate(OnLocationChangedListener onLocationChangedListener) {
|
||||
locationChangedListener = onLocationChangedListener;
|
||||
|
||||
int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper());
|
||||
int err = mTencentLocationManager.requestLocationUpdates(mTencentLocationRequest, this, Looper.myLooper());
|
||||
switch (err) {
|
||||
case 1:
|
||||
Toast.makeText(this, "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 2:
|
||||
Toast.makeText(this, "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 3:
|
||||
Toast.makeText(this, "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -417,26 +480,17 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
locationRequest = null;
|
||||
mTencentLocationManager.removeUpdates(this);
|
||||
mTencentLocationManager = null;
|
||||
mTencentLocationRequest = null;
|
||||
locationChangedListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "failed");
|
||||
}
|
||||
|
||||
private void checkLocationPermission() {
|
||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(this,
|
||||
if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
|
||||
|| ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
ActivityCompat.requestPermissions(getActivity(),
|
||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
|
||||
PERMISSION_REQUEST_CODE);
|
||||
} else {
|
||||
@ -452,10 +506,10 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission
|
||||
//startLocationUpdates();
|
||||
} else {
|
||||
// 用户拒绝了权限请求
|
||||
Toast.makeText(this, "请授予定位权限", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getActivity(), "请授予定位权限", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
package cc.winboll.studio.positions.fragments;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/20 12:57:00
|
||||
* @Describe 拨号
|
||||
*/
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
//import com.hjq.toast.ToastUtils;
|
||||
|
||||
public class TasksFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "TasksFragment";
|
||||
|
||||
private static final String ARG_PAGE = "ARG_PAGE";
|
||||
private int mPage;
|
||||
|
||||
// public static TasksFragment newInstance(int page) {
|
||||
// Bundle args = new Bundle();
|
||||
// args.putInt(ARG_PAGE, page);
|
||||
// TasksFragment fragment = new TasksFragment();
|
||||
// fragment.setArguments(args);
|
||||
// return fragment;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// if (getArguments()!= null) {
|
||||
// mPage = getArguments().getInt(ARG_PAGE);
|
||||
// }
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View viewMain = inflater.inflate(R.layout.fragment_tasks, container, false);
|
||||
// Toolbar toolbar = viewMain.findViewById(R.id.toolbar);
|
||||
// getActivity().getMenuInflater().inflate(R.menu.toolbar_tasks, toolbar.getMenu());
|
||||
//
|
||||
|
||||
return viewMain;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.toolbar_tasks, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.item_addtask) {
|
||||
ToastUtils.show("item_addtask");
|
||||
}
|
||||
// } else
|
||||
// if (item.getItemId() == R.id.item_exit) {
|
||||
// exit();
|
||||
// return true;
|
||||
// }
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
package cc.winboll.studio.positions.gps;
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
package cc.winboll.studio.positions.listeners;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/03 14:01:18
|
||||
* @Describe 手机 GPS 实时位置监听类
|
||||
*/
|
||||
import android.location.Location;
|
||||
|
||||
public interface OnGPSRTLocationListener {
|
||||
|
||||
public static final String TAG = "OnGPSRTLocationListener";
|
||||
|
||||
void onGPSRTLocation(Location location);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cc.winboll.studio.positions.listeners;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/03 13:06:13
|
||||
* @Describe 位置监听类
|
||||
*/
|
||||
import android.location.Location;
|
||||
|
||||
public interface OnTXRTLocationListener {
|
||||
|
||||
public static final String TAG = "OnTXRTLocationListener";
|
||||
|
||||
void onTXRTLocation(Location location);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cc.winboll.studio.positions.beans;
|
||||
package cc.winboll.studio.positions.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
@ -0,0 +1,108 @@
|
||||
package cc.winboll.studio.positions.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/21 10:11:36
|
||||
* @Describe 定位数据修正模型
|
||||
*/
|
||||
import android.location.Location;
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import java.io.File;
|
||||
|
||||
public class PostionFixModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "PostionFixModel";
|
||||
|
||||
// 纬度校验数据模型
|
||||
private double latitudeFixModel;
|
||||
// 经度校验数据模型
|
||||
private double longitudeFixModel;
|
||||
|
||||
public PostionFixModel() {
|
||||
this.latitudeFixModel = 0;
|
||||
this.longitudeFixModel = 0;
|
||||
}
|
||||
|
||||
public PostionFixModel(double latitudeFixModel, double longitudeFixModel) {
|
||||
this.latitudeFixModel = latitudeFixModel;
|
||||
this.longitudeFixModel = longitudeFixModel;
|
||||
}
|
||||
|
||||
public void setLatitudeFixModel(double latitudeFixModel) {
|
||||
this.latitudeFixModel = latitudeFixModel;
|
||||
}
|
||||
|
||||
public double getLatitudeFixModel() {
|
||||
return latitudeFixModel;
|
||||
}
|
||||
|
||||
public void setLongitudeFixModel(double longitudeFixModel) {
|
||||
this.longitudeFixModel = longitudeFixModel;
|
||||
}
|
||||
|
||||
public double getLongitudeFixModel() {
|
||||
return longitudeFixModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return PostionFixModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("latitudeFixModel").value(getLatitudeFixModel());
|
||||
jsonWriter.name("longitudeFixModel").value(getLongitudeFixModel());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("latitudeFixModel")) {
|
||||
setLatitudeFixModel(jsonReader.nextDouble());
|
||||
} else if (name.equals("longitudeFixModel")) {
|
||||
setLongitudeFixModel(jsonReader.nextDouble());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void savePostionFixModel(PostionFixModel model) {
|
||||
saveBeanToFile(getPostionFixModelDataPath(), model);
|
||||
}
|
||||
|
||||
public static PostionFixModel loadPostionFixModel() {
|
||||
PostionFixModel model = loadBeanFromFile(getPostionFixModelDataPath(), PostionFixModel.class);
|
||||
if(model == null) {
|
||||
model = new PostionFixModel();
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
static String getPostionFixModelDataPath() {
|
||||
return App.szDataFolder + File.separator + TAG + ".data";
|
||||
}
|
||||
}
|
@ -1,41 +1,90 @@
|
||||
package cc.winboll.studio.positions.beans;
|
||||
package cc.winboll.studio.positions.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/02/25 02:58:33
|
||||
* @Describe LocationJson
|
||||
*/
|
||||
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
import android.location.Location;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LocationJson extends BaseBean {
|
||||
|
||||
public static final String TAG = "LocationJson";
|
||||
public class PostionModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "PostionModel";
|
||||
|
||||
// UUID 唯一位置标识
|
||||
private String uuid;
|
||||
// 纬度
|
||||
private double latitude;
|
||||
// 经度
|
||||
private double longitude;
|
||||
// 标记时间
|
||||
private long timestamp;
|
||||
// 精确度
|
||||
private double accuracy;
|
||||
private String provider;
|
||||
private String comments;
|
||||
private boolean isEnable;
|
||||
private boolean isSimpleView;
|
||||
|
||||
public LocationJson() {
|
||||
public PostionModel() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.latitude = 0.0f;
|
||||
this.longitude = 0.0f;
|
||||
this.timestamp = 0L;
|
||||
this.accuracy = 0.0f;
|
||||
this.provider = "";
|
||||
this.comments = "";
|
||||
this.isEnable = false;
|
||||
this.isSimpleView = true;
|
||||
}
|
||||
|
||||
public LocationJson(Location location) {
|
||||
public PostionModel(Location location) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.latitude = location.getLatitude();
|
||||
this.longitude = location.getLongitude();
|
||||
this.timestamp = location.getTime();
|
||||
this.accuracy = location.getAccuracy();
|
||||
this.provider = location.getProvider();
|
||||
this.comments = "";
|
||||
this.isEnable = false;
|
||||
this.isSimpleView = true;
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public void setComments(String comments) {
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
public String getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public void setIsSimpleView(boolean isSimpleView) {
|
||||
this.isSimpleView = isSimpleView;
|
||||
}
|
||||
|
||||
public boolean isSimpleView() {
|
||||
return isSimpleView;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
@ -81,24 +130,30 @@ public class LocationJson extends BaseBean {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return LocationJson.class.getName();
|
||||
return PostionModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("uuid").value(getUuid());
|
||||
jsonWriter.name("latitude").value(getLatitude());
|
||||
jsonWriter.name("longitude").value(getLongitude());
|
||||
jsonWriter.name("timestamp").value(getTimestamp());
|
||||
jsonWriter.name("accuracy").value(getAccuracy());
|
||||
jsonWriter.name("provider").value(getProvider());
|
||||
jsonWriter.name("comments").value(getComments());
|
||||
jsonWriter.name("isEnable").value(isEnable());
|
||||
jsonWriter.name("isSimpleView").value(isSimpleView());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("latitude")) {
|
||||
if (name.equals("uuid")) {
|
||||
setUuid(jsonReader.nextString());
|
||||
} else if (name.equals("latitude")) {
|
||||
setLatitude(jsonReader.nextDouble());
|
||||
} else if (name.equals("longitude")) {
|
||||
setLongitude(jsonReader.nextDouble());
|
||||
@ -108,6 +163,12 @@ public class LocationJson extends BaseBean {
|
||||
setAccuracy(jsonReader.nextDouble());
|
||||
} else if (name.equals("provider")) {
|
||||
setProvider(jsonReader.nextString());
|
||||
} else if (name.equals("comments")) {
|
||||
setComments(jsonReader.nextString());
|
||||
} else if (name.equals("isEnable")) {
|
||||
setIsEnable(jsonReader.nextBoolean());
|
||||
} else if (name.equals("isSimpleView")) {
|
||||
setIsSimpleView(jsonReader.nextBoolean());
|
||||
} else {
|
||||
return false;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cc.winboll.studio.positions.beans;
|
||||
package cc.winboll.studio.positions.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
@ -0,0 +1,173 @@
|
||||
package cc.winboll.studio.positions.models;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/07 13:30:41
|
||||
* @Describe 提醒任务单一任务模型
|
||||
*/
|
||||
import android.util.JsonReader;
|
||||
import android.util.JsonWriter;
|
||||
import cc.winboll.studio.libappbase.BaseBean;
|
||||
import java.io.IOException;
|
||||
import android.location.Location;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TaskModel extends BaseBean {
|
||||
|
||||
public static final String TAG = "TaskModel";
|
||||
|
||||
enum AROUND_CONDITIONAL { WITHIN, BEYOND };
|
||||
|
||||
// UUID 唯一任务标识
|
||||
private String uuid;
|
||||
// 距离任务中心点的方圆半径(米)
|
||||
private int aroundMeters;
|
||||
// 方圆半径区域选择条件
|
||||
private AROUND_CONDITIONAL aroundConditional;
|
||||
// 任务生效时间戳
|
||||
private long taskEnableTimestamp;
|
||||
// 任务过期时间戳
|
||||
private long taskDisableTimestamp;
|
||||
// 任务描述
|
||||
private String comments;
|
||||
// 是否启用
|
||||
private boolean isEnable;
|
||||
// 在UI列表中是否显示简单视图
|
||||
private boolean isSimpleView;
|
||||
|
||||
public TaskModel() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.aroundMeters = 0;
|
||||
this.aroundConditional = AROUND_CONDITIONAL.WITHIN;
|
||||
this.taskEnableTimestamp = System.currentTimeMillis();
|
||||
this.taskDisableTimestamp = System.currentTimeMillis();
|
||||
this.comments = "";
|
||||
this.isEnable = false;
|
||||
this.isSimpleView = true;
|
||||
}
|
||||
|
||||
public TaskModel(String uuid, int aroundMeters, AROUND_CONDITIONAL aroundConditional, long taskEnableTimestamp, long taskDisableTimestamp, String comments, boolean isEnable, boolean isSimpleView) {
|
||||
this.uuid = uuid;
|
||||
this.aroundMeters = aroundMeters;
|
||||
this.aroundConditional = aroundConditional;
|
||||
this.taskEnableTimestamp = taskEnableTimestamp;
|
||||
this.taskDisableTimestamp = taskDisableTimestamp;
|
||||
this.comments = comments;
|
||||
this.isEnable = isEnable;
|
||||
this.isSimpleView = isSimpleView;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setAroundMeters(int aroundMeters) {
|
||||
this.aroundMeters = aroundMeters;
|
||||
}
|
||||
|
||||
public int getAroundMeters() {
|
||||
return aroundMeters;
|
||||
}
|
||||
|
||||
public void setAroundConditional(AROUND_CONDITIONAL aroundConditional) {
|
||||
this.aroundConditional = aroundConditional;
|
||||
}
|
||||
|
||||
public AROUND_CONDITIONAL getAroundConditional() {
|
||||
return aroundConditional;
|
||||
}
|
||||
|
||||
public void setTaskEnableTimestamp(long taskEnableTimestamp) {
|
||||
this.taskEnableTimestamp = taskEnableTimestamp;
|
||||
}
|
||||
|
||||
public long getTaskEnableTimestamp() {
|
||||
return taskEnableTimestamp;
|
||||
}
|
||||
|
||||
public void setTaskDisableTimestamp(long taskDisableTimestamp) {
|
||||
this.taskDisableTimestamp = taskDisableTimestamp;
|
||||
}
|
||||
|
||||
public long getTaskDisableTimestamp() {
|
||||
return taskDisableTimestamp;
|
||||
}
|
||||
|
||||
public void setComments(String comments) {
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
public String getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
public void setIsEnable(boolean isEnable) {
|
||||
this.isEnable = isEnable;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return isEnable;
|
||||
}
|
||||
|
||||
public void setIsSimpleView(boolean isSimpleView) {
|
||||
this.isSimpleView = isSimpleView;
|
||||
}
|
||||
|
||||
public boolean isSimpleView() {
|
||||
return isSimpleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return TaskModel.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeThisToJsonWriter(JsonWriter jsonWriter) throws IOException {
|
||||
super.writeThisToJsonWriter(jsonWriter);
|
||||
jsonWriter.name("uuid").value(getUuid());
|
||||
jsonWriter.name("aroundMeters").value(getUuid());
|
||||
jsonWriter.name("aroundConditional").value(getComments());
|
||||
jsonWriter.name("taskEnableTimestamp").value(isEnable());
|
||||
jsonWriter.name("taskDisableTimestamp").value(isSimpleView());
|
||||
jsonWriter.name("comments").value(getComments());
|
||||
jsonWriter.name("isEnable").value(isEnable());
|
||||
jsonWriter.name("isSimpleView").value(isSimpleView());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initObjectsFromJsonReader(JsonReader jsonReader, String name) throws IOException {
|
||||
if (super.initObjectsFromJsonReader(jsonReader, name)) { return true; } else {
|
||||
if (name.equals("uuid")) {
|
||||
setUuid(jsonReader.nextString());
|
||||
} else if (name.equals("comments")) {
|
||||
setComments(jsonReader.nextString());
|
||||
} else if (name.equals("isEnable")) {
|
||||
setIsEnable(jsonReader.nextBoolean());
|
||||
} else if (name.equals("isSimpleView")) {
|
||||
setIsSimpleView(jsonReader.nextBoolean());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBean readBeanFromJsonReader(JsonReader jsonReader) throws IOException {
|
||||
jsonReader.beginObject();
|
||||
while (jsonReader.hasNext()) {
|
||||
String name = jsonReader.nextName();
|
||||
if (!initObjectsFromJsonReader(jsonReader, name)) {
|
||||
jsonReader.skipValue();
|
||||
}
|
||||
}
|
||||
// 结束 JSON 对象
|
||||
jsonReader.endObject();
|
||||
return this;
|
||||
}
|
||||
}
|
@ -10,8 +10,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
//import com.hjq.toast.ToastUtils;
|
||||
import java.lang.ref.WeakReference;
|
||||
import cc.winboll.studio.libappbase.utils.ToastUtils;
|
||||
|
||||
public class MainReceiver extends BroadcastReceiver {
|
||||
|
||||
|
@ -12,11 +12,9 @@ import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.positions.beans.MainServiceBean;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import cc.winboll.studio.positions.models.MainServiceBean;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
|
||||
public class AssistantService extends Service {
|
||||
|
||||
|
@ -0,0 +1,108 @@
|
||||
package cc.winboll.studio.positions.services;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import cc.winboll.studio.positions.listeners.OnGPSRTLocationListener;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/03 12:13:23
|
||||
* @Describe 获取实时 GPS 数据的服务
|
||||
*/
|
||||
public class GPSService extends Service {
|
||||
|
||||
public static final String TAG = "GPSService";
|
||||
|
||||
OnGPSRTLocationListener mOnGPSRTLocationListener;
|
||||
LocationManager locationManager;
|
||||
Location mLocationPhoneGPS;
|
||||
Location mLocationNetwork;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return new MyBinder();
|
||||
}
|
||||
|
||||
// 用于返回服务实例的Binder
|
||||
public class MyBinder extends Binder {
|
||||
public GPSService getService() {
|
||||
return GPSService.this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
// 请求GPS定位
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, phoneGPSLocationListener);
|
||||
// 请求基站(网络)定位
|
||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, networkLocationListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (locationManager != null) {
|
||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
return;
|
||||
}
|
||||
locationManager.removeUpdates(phoneGPSLocationListener);
|
||||
locationManager.removeUpdates(networkLocationListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnGPSRTLocationListener(OnGPSRTLocationListener listener) {
|
||||
mOnGPSRTLocationListener = listener;
|
||||
}
|
||||
|
||||
private LocationListener phoneGPSLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理GPS定位结果
|
||||
if (location != null && mOnGPSRTLocationListener != null) {
|
||||
mLocationPhoneGPS = location;
|
||||
mOnGPSRTLocationListener.onGPSRTLocation(mLocationPhoneGPS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
|
||||
private LocationListener networkLocationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
// 处理基站(网络)定位结果
|
||||
if (location != null) {
|
||||
mLocationNetwork = location;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||
|
||||
@Override
|
||||
public void onProviderEnabled(String provider) {}
|
||||
|
||||
@Override
|
||||
public void onProviderDisabled(String provider) {}
|
||||
};
|
||||
}
|
@ -18,9 +18,10 @@ import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import cc.winboll.studio.positions.beans.MainServiceBean;
|
||||
import cc.winboll.studio.libappbase.sos.SOS;
|
||||
import cc.winboll.studio.libappbase.sos.WinBoll;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import cc.winboll.studio.positions.models.MainServiceBean;
|
||||
import cc.winboll.studio.positions.handlers.MainServiceHandler;
|
||||
import cc.winboll.studio.positions.receivers.MainReceiver;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
@ -89,14 +90,18 @@ public class MainService extends Service {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
// 召唤 WinBoll APP 绑定本服务
|
||||
SOS.bindToAPPService(this, new APPSOSBean(getPackageName(), MainService.class.getName()));
|
||||
if (App.isDebuging()) {
|
||||
WinBoll.bindToAPPBaseBeta(this, MainService.class.getName());
|
||||
} else {
|
||||
WinBoll.bindToAPPBase(this, MainService.class.getName());
|
||||
}
|
||||
|
||||
if (mMainReceiver == null) {
|
||||
// 注册广播接收器
|
||||
mMainReceiver = new MainReceiver(this);
|
||||
mMainReceiver.registerAction(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainServiceThread.getInstance(this, mMainServiceHandler).start();
|
||||
|
||||
@ -172,7 +177,11 @@ public class MainService extends Service {
|
||||
if (mMainServiceBean.isEnable()) {
|
||||
// 唤醒守护进程
|
||||
wakeupAndBindAssistant();
|
||||
SOS.sosWinBollService(getApplicationContext(), new APPSOSBean(getPackageName(), MainService.class.getName()));
|
||||
if (App.isDebuging()) {
|
||||
SOS.sosToAppBaseBeta(MainService.this, MainService.class.getName());
|
||||
} else {
|
||||
SOS.sosToAppBase(MainService.this, MainService.class.getName());
|
||||
}
|
||||
}
|
||||
isBound = false;
|
||||
mAssistantService = null;
|
||||
|
@ -5,12 +5,8 @@ package cc.winboll.studio.positions.threads;
|
||||
* @Date 2025/02/14 03:46:44
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.positions.handlers.MainServiceHandler;
|
||||
import cc.winboll.studio.positions.services.MainService;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.libappbase.SOS;
|
||||
import cc.winboll.studio.libappbase.bean.APPSOSBean;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import cc.winboll.studio.positions.handlers.MainServiceHandler;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class MainServiceThread extends Thread {
|
||||
|
@ -15,28 +15,34 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.json.JSONArray;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
import cc.winboll.studio.positions.beans.LocationJson;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import cc.winboll.studio.positions.App;
|
||||
import java.io.File;
|
||||
|
||||
public class LocationFileStorage {
|
||||
public static final String TAG = "LocationFileStorage";
|
||||
|
||||
private static final String FILE_NAME = "locations.json";
|
||||
static final String FILE_NAME = "locations.json";
|
||||
|
||||
public static void saveToFile(Context context, ArrayList<LocationJson> locations) {
|
||||
public static void saveToFile(Context context, ArrayList<PostionModel> locations) {
|
||||
try {
|
||||
LocationJson.saveBeanList(context, locations, LocationJson.class);
|
||||
PostionModel.saveBeanListToFile(getDataPath(), locations);
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<LocationJson> loadFromFile(Context context) {
|
||||
ArrayList<LocationJson> result = new ArrayList<LocationJson>();
|
||||
public static ArrayList<PostionModel> loadFromFile(Context context) {
|
||||
ArrayList<PostionModel> result = new ArrayList<PostionModel>();
|
||||
try {
|
||||
LocationJson.loadBeanList(context, result, LocationJson.class);
|
||||
PostionModel.loadBeanListFromFile(getDataPath(), result, PostionModel.class);
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, e, Thread.currentThread().getStackTrace());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static String getDataPath() {
|
||||
return App.szDataFolder + File.separator + FILE_NAME;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/11 09:36:52
|
||||
* @Describe 定位数据融合类
|
||||
*/
|
||||
import cc.winboll.studio.positions.App;
|
||||
import java.io.File;
|
||||
|
||||
public class LocationFusion {
|
||||
|
||||
public static final String TAG = "LocationFusion";
|
||||
|
||||
static final String FILE_NAME = "LocationFusionModel.json";
|
||||
|
||||
// 融合定位数据的方法
|
||||
public static double[] fuseLocationData(double latitudeGPSLock, double longitudeGPSLock,
|
||||
double latitudeWifiLock, double longitudeWifiLock, double gpsWeight, double wifiWeight) {
|
||||
if (gpsWeight + wifiWeight != 1) {
|
||||
throw new IllegalArgumentException("GPS权重和Wi-Fi权重之和必须为1");
|
||||
}
|
||||
double lat = latitudeGPSLock * gpsWeight + latitudeWifiLock * wifiWeight;
|
||||
double lon = longitudeGPSLock * gpsWeight + longitudeWifiLock * wifiWeight;
|
||||
return new double[]{lat, lon};
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// double[] gpsLocation = {30.5, 120.5};
|
||||
// double[] wifiLocation = {30.6, 120.6};
|
||||
// double gpsWeight = 0.6;
|
||||
// double wifiWeight = 0.4;
|
||||
// double[] fusedLocation = fuseLocationData(gpsLocation, wifiLocation, gpsWeight, wifiWeight);
|
||||
// System.out.println("融合后的纬度: " + fusedLocation[0] + ", 经度: " + fusedLocation[1]);
|
||||
// }
|
||||
|
||||
static String getDataPath() {
|
||||
return App.szDataFolder + File.separator + FILE_NAME;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/04/03 21:09:50
|
||||
* @Describe 位置处理工具集
|
||||
*/
|
||||
import android.content.Context;
|
||||
import cc.winboll.studio.positions.models.PostionModel;
|
||||
import java.util.ArrayList;
|
||||
import android.location.Location;
|
||||
|
||||
public class PostionUtils {
|
||||
|
||||
public static final String TAG = "PostionUtils";
|
||||
|
||||
static volatile PostionUtils _PostionUtils;
|
||||
|
||||
Context mContext;
|
||||
ArrayList<PostionModel> mPostionModelList = new ArrayList<PostionModel>();
|
||||
|
||||
PostionUtils(Context context) {
|
||||
mContext = context;
|
||||
PostionModel.loadBeanList(mContext, mPostionModelList, PostionModel.class);
|
||||
}
|
||||
|
||||
public synchronized static PostionUtils getInstance(Context context) {
|
||||
if (_PostionUtils == null) {
|
||||
_PostionUtils = new PostionUtils(context);
|
||||
}
|
||||
return _PostionUtils;
|
||||
}
|
||||
|
||||
public ArrayList<PostionModel> getPostionModelList() {
|
||||
return mPostionModelList;
|
||||
}
|
||||
|
||||
public void savePostionModelList() {
|
||||
PostionModel.saveBeanList(mContext, mPostionModelList, PostionModel.class);
|
||||
}
|
||||
|
||||
public void addPostion(PostionModel item) {
|
||||
mPostionModelList.add(item);
|
||||
PostionModel.saveBeanList(mContext, mPostionModelList, PostionModel.class);
|
||||
}
|
||||
|
||||
public void addPostion(Location location) {
|
||||
PostionModel item = new PostionModel();
|
||||
item.setLatitude(location.getLatitude());
|
||||
item.setLongitude(location.getLongitude());
|
||||
item.setTimestamp(location.getTime());
|
||||
item.setAccuracy(location.getAccuracy());
|
||||
item.setProvider(location.getProvider());
|
||||
|
||||
mPostionModelList.add(item);
|
||||
PostionModel.saveBeanList(mContext, mPostionModelList, PostionModel.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cc.winboll.studio.positions.utils;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/21 16:02:56
|
||||
* @Describe 时间工具集
|
||||
*/
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class TimeUtils {
|
||||
|
||||
public static final String TAG = "TimeUtils";
|
||||
|
||||
public static String getCurrentTimeString() {
|
||||
// 获取当前日期时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 定义日期时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 格式化日期时间
|
||||
String formattedDateTime = now.format(formatter);
|
||||
//System.out.println(formattedDateTime);
|
||||
return formattedDateTime;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,219 @@
|
||||
package cc.winboll.studio.positions.views;
|
||||
|
||||
/**
|
||||
* @Author ZhanGSKen@AliYun.Com
|
||||
* @Date 2025/03/04 10:51:50
|
||||
* @Describe CustomHorizontalScrollView
|
||||
*/
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import cc.winboll.studio.libappbase.LogUtils;
|
||||
|
||||
public class LeftScrollView extends HorizontalScrollView {
|
||||
|
||||
public static final String TAG = "LeftScrollView";
|
||||
|
||||
private LinearLayout contentLayout;
|
||||
private LinearLayout toolLayout;
|
||||
private TextView textView;
|
||||
private Button editButton;
|
||||
private Button deleteButton;
|
||||
private Button upButton;
|
||||
private Button downButton;
|
||||
private float mStartX;
|
||||
private float mEndX;
|
||||
private boolean isScrolling = false;
|
||||
private int nScrollAcceptSize;
|
||||
|
||||
public LeftScrollView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public LeftScrollView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public LeftScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
public void addContentLayout(TextView textView) {
|
||||
contentLayout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
|
||||
public void setContentWidth(int contentWidth) {
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) contentLayout.getLayoutParams();
|
||||
layoutParams.width = contentWidth;
|
||||
contentLayout.setLayoutParams(layoutParams);
|
||||
|
||||
}
|
||||
|
||||
private void init() {
|
||||
View viewMain = inflate(getContext(), R.layout.view_left_scroll, null);
|
||||
|
||||
// 创建内容布局
|
||||
contentLayout = viewMain.findViewById(R.id.content_layout);
|
||||
toolLayout = viewMain.findViewById(R.id.action_layout);
|
||||
|
||||
//LogUtils.d(TAG, String.format("getWidth() %d", getWidth()));
|
||||
|
||||
addView(viewMain);
|
||||
|
||||
// 创建编辑按钮
|
||||
editButton = viewMain.findViewById(R.id.edit_btn);
|
||||
// 创建删除按钮
|
||||
deleteButton = viewMain.findViewById(R.id.delete_btn);
|
||||
// 向上按钮
|
||||
upButton = viewMain.findViewById(R.id.up_btn);
|
||||
// 向下按钮
|
||||
downButton = viewMain.findViewById(R.id.down_btn);
|
||||
|
||||
// 编辑按钮点击事件
|
||||
editButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onActionListener != null) {
|
||||
onActionListener.onEdit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 删除按钮点击事件
|
||||
deleteButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onActionListener != null) {
|
||||
onActionListener.onDelete();
|
||||
}
|
||||
}
|
||||
});
|
||||
// 编辑按钮点击事件
|
||||
upButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onActionListener != null) {
|
||||
onActionListener.onUp();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 删除按钮点击事件
|
||||
downButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onActionListener != null) {
|
||||
onActionListener.onDown();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
LogUtils.d(TAG, "ACTION_DOWN");
|
||||
mStartX = event.getX();
|
||||
// isScrolling = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
//LogUtils.d(TAG, "ACTION_MOVE");
|
||||
// float currentX = event.getX();
|
||||
// float deltaX = mStartX - currentX;
|
||||
// //mLastX = currentX;
|
||||
// if (Math.abs(deltaX) > 0) {
|
||||
// isScrolling = true;
|
||||
// }
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (getScrollX() > 0) {
|
||||
LogUtils.d(TAG, "ACTION_UP");
|
||||
mEndX = event.getX();
|
||||
LogUtils.d(TAG, String.format("mStartX %f, mEndX %f", mStartX, mEndX));
|
||||
if (mEndX < mStartX) {
|
||||
LogUtils.d(TAG, String.format("mEndX >= mStartX \ngetScrollX() %d", getScrollX()));
|
||||
//if (getScrollX() > editButton.getWidth()) {
|
||||
if (Math.abs(mStartX - mEndX) > editButton.getWidth()) {
|
||||
smoothScrollToRight();
|
||||
} else {
|
||||
smoothScrollToLeft();
|
||||
}
|
||||
} else {
|
||||
LogUtils.d(TAG, String.format("mEndX >= mStartX \ngetScrollX() %d", getScrollX()));
|
||||
//if (getScrollX() > deleteButton.getWidth()) {
|
||||
if (Math.abs(mEndX - mStartX) > deleteButton.getWidth()) {
|
||||
smoothScrollToLeft();
|
||||
} else {
|
||||
smoothScrollToRight();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
void smoothScrollToRight() {
|
||||
mEndX = 0;
|
||||
mStartX = 0;
|
||||
View childView = getChildAt(0);
|
||||
if (childView != null) {
|
||||
// 计算需要滑动到最右边的距离
|
||||
int scrollToX = childView.getWidth() - getWidth();
|
||||
// 确保滑动距离不小于0
|
||||
final int scrollToX2 = Math.max(0, scrollToX);
|
||||
// 平滑滑动到最右边
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
smoothScrollTo(scrollToX2, 0);
|
||||
LogUtils.d(TAG, "smoothScrollTo(0, 0);");
|
||||
}
|
||||
});
|
||||
LogUtils.d(TAG, "smoothScrollTo(scrollToX, 0);");
|
||||
}
|
||||
}
|
||||
|
||||
void smoothScrollToLeft() {
|
||||
mEndX = 0;
|
||||
mStartX = 0;
|
||||
// 在手指抬起时,使用 post 方法调用 smoothScrollTo(0, 0)
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
smoothScrollTo(0, 0);
|
||||
LogUtils.d(TAG, "smoothScrollTo(0, 0);");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 设置文本内容
|
||||
public void setText(CharSequence text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
// 定义回调接口
|
||||
public interface OnActionListener {
|
||||
void onEdit();
|
||||
void onDelete();
|
||||
void onUp();
|
||||
void onDown();
|
||||
}
|
||||
|
||||
private OnActionListener onActionListener;
|
||||
|
||||
public void setOnActionListener(OnActionListener listener) {
|
||||
this.onActionListener = listener;
|
||||
}
|
||||
}
|
BIN
positions/src/main/java/com/.DS_Store
vendored
BIN
positions/src/main/java/com/tencent/.DS_Store
vendored
BIN
positions/src/main/java/com/tencent/map/.DS_Store
vendored
@ -1,32 +0,0 @@
|
||||
package com.tencent.map.vector.demo;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
|
||||
public abstract class AbsListActivity extends AbsActivity {
|
||||
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_recycler_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutId());
|
||||
TencentMapInitializer.setAgreePrivacy(this, true);
|
||||
TencentMapInitializer.start(this);
|
||||
TencentLocationManager.setUserAgreePrivacy(true);
|
||||
final String PRIVACY_URL = "https://privacy.qq.com/document/preview/a10a8634f237464da9a95f4f07e73e40";
|
||||
findViewById(R.id.tv_user).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PRIVACY_URL)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package com.tencent.map.vector.demo;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
|
||||
public abstract class AbsMapActivity extends AbsActivity {
|
||||
|
||||
private TencentMap mTencentMap;
|
||||
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_map_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getLayoutId());
|
||||
|
||||
FragmentManager manager = getSupportFragmentManager();
|
||||
SupportMapFragment fragment = (SupportMapFragment) manager.findFragmentById(R.id.fragment_map);
|
||||
if (fragment != null) {
|
||||
mTencentMap = fragment.getMap();
|
||||
}
|
||||
|
||||
onCreate(savedInstanceState, mTencentMap);
|
||||
}
|
||||
|
||||
protected boolean checkMapInvalid() {
|
||||
return mTencentMap == null || mTencentMap.isDestroyed();
|
||||
}
|
||||
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
@ -1,277 +0,0 @@
|
||||
package com.tencent.map.vector.demo;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.ListAdapter;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import cc.winboll.studio.positions.R;
|
||||
|
||||
public class DemoMainActivity extends AbsListActivity {
|
||||
|
||||
private static final String DEMO_TYPE = "DEMO_TYPE";
|
||||
|
||||
private static List<DemoInfo> mDemoTypes;
|
||||
private static Map<String, List<DemoInfo>> mDemoMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getDemos();
|
||||
setupViews(getIntent().getStringExtra(DEMO_TYPE));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] onRequestPermissions() {
|
||||
return new String[]{
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_PHONE_STATE
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_demomain;
|
||||
}
|
||||
|
||||
private void setupViews(String type) {
|
||||
RecyclerView recyclerView = findViewById(R.id.layout_recycle_container);
|
||||
if (recyclerView != null) {
|
||||
RecyclerView.LayoutManager layoutManager =
|
||||
new LinearLayoutManager(getApplicationContext());
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
recyclerView.addItemDecoration(new DividerItemDecoration(
|
||||
getApplicationContext(), DividerItemDecoration.VERTICAL));
|
||||
|
||||
DemoActivityAdapter activityAdapter = new DemoActivityAdapter(type);
|
||||
recyclerView.setAdapter(activityAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
private void getDemos() {
|
||||
if (mDemoMap != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mDemoMap = new HashMap<>(16);
|
||||
mDemoTypes = new ArrayList<>(16);
|
||||
|
||||
ActivityInfo[] activityIfs = new ActivityInfo[0];
|
||||
try {
|
||||
activityIfs = getPackageManager().getPackageInfo(getPackageName(),
|
||||
PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA).activities;
|
||||
} catch (PackageManager.NameNotFoundException pE) {
|
||||
pE.printStackTrace();
|
||||
}
|
||||
|
||||
for (ActivityInfo activityInfo : activityIfs) {
|
||||
if (activityInfo.metaData != null) {
|
||||
String demoType = activityInfo.metaData.getString(
|
||||
getResources().getString(R.string.demo_type));
|
||||
List<DemoInfo> items = mDemoMap.get(demoType);
|
||||
if (items == null) {
|
||||
items = new ArrayList<>();
|
||||
mDemoMap.put(demoType, items);
|
||||
mDemoTypes.add(new DemoInfo(
|
||||
DemoMainActivity.class.getName(),
|
||||
demoType,
|
||||
""));
|
||||
}
|
||||
|
||||
items.add(new DemoInfo(
|
||||
activityInfo.name,
|
||||
getString(activityInfo.labelRes),
|
||||
getString(activityInfo.descriptionRes)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class DemoInfo {
|
||||
private String name;
|
||||
private String label;
|
||||
private String description;
|
||||
|
||||
public DemoInfo(String name, String label, String description) {
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DemoInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DemoInfo info = (DemoInfo) obj;
|
||||
|
||||
if (!Objects.equals(this.name, info.name)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.label, info.label)) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.description, info.description)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = name != null ? name.hashCode() : 0;
|
||||
hash = 31 * hash + (label != null ? label.hashCode() : 0);
|
||||
hash = 31 * hash + (description != null ? description.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
private class DemoActivityAdapter extends ListAdapter<DemoInfo, DemoInfoHolder> {
|
||||
|
||||
private int mType;
|
||||
|
||||
DemoActivityAdapter(String type) {
|
||||
super(new DiffUtil.ItemCallback<DemoInfo>() {
|
||||
@Override
|
||||
public boolean areItemsTheSame(@NonNull DemoInfo oldItem, @NonNull DemoInfo newItem) {
|
||||
return oldItem.name.equals(newItem.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(@NonNull DemoInfo oldItem, @NonNull DemoInfo newItem) {
|
||||
return oldItem.equals(newItem);
|
||||
}
|
||||
});
|
||||
if (TextUtils.isEmpty(type)) {
|
||||
mType = DemoInfoHolder.ITEM_TYPE_GROUP;
|
||||
submitList(mDemoTypes);
|
||||
} else {
|
||||
mType = DemoInfoHolder.ITEM_TYPE_ENTRY;
|
||||
submitList(mDemoMap.get(type));
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DemoInfoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new DemoInfoHolder(DemoMainActivity.this, parent, viewType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DemoInfoHolder holder, int position) {
|
||||
holder.bindView(getItem(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return mType;
|
||||
}
|
||||
}
|
||||
|
||||
static class DemoInfoHolder<T extends DemoInfo> extends RecyclerView.ViewHolder {
|
||||
|
||||
private static final int ITEM_TYPE_GROUP = 0;
|
||||
private static final int ITEM_TYPE_ENTRY = 1;
|
||||
|
||||
private int mViewType;
|
||||
|
||||
private TextView mTitle;
|
||||
private TextView mSubTitle;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
DemoInfoHolder(Context context, ViewGroup pParent, int pViewType) {
|
||||
super(LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_2, pParent, false));
|
||||
mViewType = pViewType;
|
||||
mContext = context;
|
||||
|
||||
mTitle = itemView.findViewById(android.R.id.text1);
|
||||
mTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
|
||||
mSubTitle = itemView.findViewById(android.R.id.text2);
|
||||
mSubTitle.setTextColor(Color.GRAY);
|
||||
|
||||
}
|
||||
|
||||
void bindView(T pItem) {
|
||||
if (mViewType == ITEM_TYPE_GROUP) {
|
||||
setupItemGroup(pItem);
|
||||
} else if (mViewType == ITEM_TYPE_ENTRY) {
|
||||
setupItemEntry(pItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupItemGroup(final T pItem) {
|
||||
mTitle.setText(pItem.getLabel());
|
||||
mSubTitle.setVisibility(View.GONE);
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Intent intent = new Intent(mContext, Class.forName(pItem.getName()));
|
||||
intent.putExtra(DEMO_TYPE, pItem.getLabel());
|
||||
mContext.startActivity(intent);
|
||||
} catch (ClassNotFoundException pE) {
|
||||
pE.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupItemEntry(final T pItem) {
|
||||
mTitle.setText(pItem.getLabel());
|
||||
mSubTitle.setText(pItem.getDescription());
|
||||
|
||||
itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
Intent intent = new Intent(mContext, Class.forName(pItem.getName()));
|
||||
mContext.startActivity(intent);
|
||||
} catch (ClassNotFoundException pE) {
|
||||
pE.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,544 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IndoorFloorView extends ScrollView {
|
||||
public static final String TAG = IndoorFloorView.class
|
||||
.getSimpleName();
|
||||
|
||||
private Context context;
|
||||
|
||||
private LinearLayout views;
|
||||
|
||||
private int itemHeight = 0;
|
||||
private List<String> items;
|
||||
|
||||
private int scrollDirection = -1;
|
||||
private static final int SCROLL_DIRECTION_UP = 0;
|
||||
private static final int SCROLL_DIRECTION_DOWN = 1;
|
||||
|
||||
private int viewWidth;
|
||||
|
||||
private Bitmap selectBitmap = null;
|
||||
//背景色
|
||||
private int backGroundColor = Color.parseColor("#00000000");
|
||||
//边框色
|
||||
private int strokeColor = Color.parseColor("#00000000");
|
||||
private int strokeWidth = 0; // 边框宽度
|
||||
|
||||
private int offset = 1; // 偏移量在最前面和最后面补全
|
||||
private int displayItemCount; // 每页显示的数
|
||||
int selectedIndex = 1;
|
||||
|
||||
private int initialY;
|
||||
|
||||
private Runnable scrollerTask;
|
||||
private int newCheck = 50;
|
||||
|
||||
public IndoorFloorView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public IndoorFloorView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public IndoorFloorView(Context context, AttributeSet attrs,
|
||||
int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改偏移量,即当第一个显示在中间是上面有几个空白<br>
|
||||
* 也会影响整体显示,如设置1,上下各偏移1,总共显3个;设置2总共显示5个;
|
||||
*
|
||||
* @param offset
|
||||
*/
|
||||
public void setOffset(int offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
private void init(Context context) {
|
||||
this.context = context;
|
||||
|
||||
this.setVerticalScrollBarEnabled(false);
|
||||
|
||||
selectBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.radius);
|
||||
|
||||
views = new LinearLayout(context);
|
||||
views.setOrientation(LinearLayout.VERTICAL);
|
||||
this.addView(views);
|
||||
scrollerTask = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
||||
int newY = getScrollY();
|
||||
if (initialY - newY == 0) { // stopped
|
||||
final int remainder = initialY % itemHeight;
|
||||
final int divided = initialY / itemHeight;
|
||||
if (remainder == 0) {
|
||||
selectedIndex = divided + offset;
|
||||
|
||||
onSeletedCallBack();
|
||||
} else {
|
||||
if (remainder > itemHeight / 2) {
|
||||
IndoorFloorView.this.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IndoorFloorView.this.smoothScrollTo(
|
||||
0, initialY - remainder
|
||||
+ itemHeight);
|
||||
selectedIndex = divided + offset + 1;
|
||||
onSeletedCallBack();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
IndoorFloorView.this.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IndoorFloorView.this.smoothScrollTo(
|
||||
0, initialY - remainder);
|
||||
selectedIndex = divided + offset;
|
||||
onSeletedCallBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
initialY = getScrollY();
|
||||
IndoorFloorView.this.postDelayed(scrollerTask,
|
||||
newCheck);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public void startScrollerTask() {
|
||||
|
||||
initialY = getScrollY();
|
||||
this.postDelayed(scrollerTask, newCheck);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
if(items==null||items.size()==0){
|
||||
return;
|
||||
}
|
||||
|
||||
views.removeAllViews();
|
||||
displayItemCount = offset * 2 + 1;
|
||||
|
||||
for (int i=items.size()-1;i>=0;i--) {
|
||||
views.addView(createView(items.get(i)));
|
||||
}
|
||||
|
||||
refreshItemView(0);
|
||||
}
|
||||
|
||||
private TextView createView(String item) {
|
||||
TextView tv = new TextView(context);
|
||||
tv.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
tv.setSingleLine(true);
|
||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
||||
tv.setText(item);
|
||||
tv.setGravity(Gravity.CENTER);
|
||||
TextPaint tp = tv.getPaint();
|
||||
tp.setFakeBoldText(true);
|
||||
int padding_h = dip2px(context, 8);
|
||||
int padding_v = dip2px(context, 6);
|
||||
tv.setPadding(padding_h, padding_v, padding_h, padding_v);
|
||||
if (0 == itemHeight) {
|
||||
itemHeight = getViewMeasuredHeight(tv);
|
||||
views.setLayoutParams(new LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, itemHeight
|
||||
* displayItemCount));
|
||||
this.setLayoutParams(new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, itemHeight * displayItemCount));
|
||||
}
|
||||
return tv;
|
||||
}
|
||||
|
||||
private void refreshItemView(int y) {
|
||||
int position = y / itemHeight + offset;
|
||||
int remainder = y % itemHeight;
|
||||
int divided = y / itemHeight;
|
||||
|
||||
if (remainder == 0) {
|
||||
position = divided + offset;
|
||||
} else {
|
||||
if (remainder > itemHeight / 2) {
|
||||
position = divided + offset + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int childSize = views.getChildCount();
|
||||
for (int i = 0; i < childSize; i++) {
|
||||
TextView itemView = (TextView) views.getChildAt(i);
|
||||
if (null == itemView) {
|
||||
return;
|
||||
}
|
||||
if (position == i) {
|
||||
itemView.setTextColor(Color.parseColor("#0079ff"));
|
||||
} else {
|
||||
itemView.setTextColor(Color.parseColor("#ccebfc"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示的内容
|
||||
*
|
||||
* @param list
|
||||
*/
|
||||
public void setItems(List<String> list) {
|
||||
if (null == items) {
|
||||
items = new ArrayList<String>();
|
||||
}
|
||||
items.clear();
|
||||
items.addAll(list);
|
||||
|
||||
// 前面和后面补
|
||||
for (int i = 0; i < offset; i++) {
|
||||
items.add(0, "");
|
||||
items.add("");
|
||||
}
|
||||
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置显示的内容
|
||||
*
|
||||
* @param strs
|
||||
*/
|
||||
public void setItems(String[] strs) {
|
||||
if (null == items) {
|
||||
items = new ArrayList<String>();
|
||||
}
|
||||
|
||||
items.clear();
|
||||
for (int i = 0; i < strs.length; i++)
|
||||
items.add(strs[i]);
|
||||
|
||||
// 前面和后面补
|
||||
for (int i = 0; i < offset; i++) {
|
||||
items.add(0, "");
|
||||
items.add("");
|
||||
}
|
||||
|
||||
initData();
|
||||
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int color) {
|
||||
this.backGroundColor = color;
|
||||
}
|
||||
|
||||
public void setStrokeColor(int color) {
|
||||
this.strokeColor = color;
|
||||
}
|
||||
|
||||
public void setStrokeWidth(int width) {
|
||||
this.strokeWidth = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置选中状图片
|
||||
*
|
||||
* @param bitmap
|
||||
*/
|
||||
public void setIndoorSelectBitmap(Bitmap bitmap) {
|
||||
this.selectBitmap = bitmap;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (selectBitmap != null && !selectBitmap.isRecycled()) {
|
||||
selectBitmap.recycle();
|
||||
selectBitmap = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundDrawable(Drawable background) {
|
||||
if (viewWidth == 0) {
|
||||
viewWidth = ((Activity) context).getWindowManager()
|
||||
.getDefaultDisplay().getWidth();
|
||||
}
|
||||
|
||||
background = new Drawable() {
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
|
||||
try {
|
||||
drawBg(canvas);
|
||||
drawCenterLine(canvas);
|
||||
drawStroke(canvas);
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void drawBg(Canvas canvas) {
|
||||
canvas.drawColor(backGroundColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param canvas
|
||||
*/
|
||||
private void drawCenterLine(Canvas canvas) {
|
||||
final Paint paint = new Paint();
|
||||
Rect src = new Rect();// 图片 >>原矩
|
||||
Rect dst = new Rect();// 屏幕 >>目标矩形
|
||||
//133 122
|
||||
Log.d("IndoorFloorView", "drawCenterLine: "+selectBitmap.getWidth()+"\n"+selectBitmap.getHeight());
|
||||
src.left = 0;
|
||||
src.top = 0;
|
||||
src.right = 0 + selectBitmap.getWidth();
|
||||
src.bottom = 0 + selectBitmap.getHeight();
|
||||
|
||||
dst.left = 0;
|
||||
dst.top = obtainSelectedAreaBorder()[0];
|
||||
dst.right = 0 + viewWidth;
|
||||
dst.bottom = obtainSelectedAreaBorder()[1];
|
||||
canvas.drawBitmap(selectBitmap, src, dst, paint);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param canvas
|
||||
*/
|
||||
private void drawStroke(Canvas canvas) {
|
||||
final Paint mPaint = new Paint();
|
||||
Rect rect = canvas.getClipBounds();
|
||||
mPaint.setColor(strokeColor);
|
||||
mPaint.setStyle(Paint.Style.STROKE);
|
||||
mPaint.setStrokeWidth(strokeWidth);
|
||||
canvas.drawRect(rect, mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
super.setBackgroundDrawable(background);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选中区域的边
|
||||
*/
|
||||
private int[] obtainSelectedAreaBorder() {
|
||||
int[] selectedAreaBorder = null;
|
||||
if (null == selectedAreaBorder) {
|
||||
selectedAreaBorder = new int[2];
|
||||
selectedAreaBorder[0] = itemHeight * offset;
|
||||
selectedAreaBorder[1] = itemHeight * (offset + 1);
|
||||
}
|
||||
return selectedAreaBorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
viewWidth = w;
|
||||
setBackgroundDrawable(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||
super.onScrollChanged(l, t, oldl, oldt);
|
||||
refreshItemView(t);
|
||||
if (t > oldt) {
|
||||
scrollDirection = SCROLL_DIRECTION_DOWN;
|
||||
} else {
|
||||
scrollDirection = SCROLL_DIRECTION_UP;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中回调
|
||||
*/
|
||||
private void onSeletedCallBack() {
|
||||
if (null != onIndoorFloorSwtichListener) {
|
||||
try {
|
||||
onIndoorFloorSwtichListener.onSelected(getSeletedIndex());
|
||||
} catch (Throwable e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setSeletion(String selectValue) {
|
||||
if(items==null||items.size()==0){
|
||||
return;
|
||||
}
|
||||
int position = items.indexOf(selectValue);
|
||||
final int p = items.size()-offset-1-position;
|
||||
selectedIndex = p + offset;
|
||||
this.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IndoorFloorView.this.smoothScrollTo(0, p * itemHeight);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public String getSeletedItem() {
|
||||
return items.get(selectedIndex);
|
||||
}
|
||||
|
||||
public int getSeletedIndex() {
|
||||
if(items==null||items.size()==0){
|
||||
return 0;
|
||||
}
|
||||
int result = items.size()-1-selectedIndex - offset;
|
||||
return Math.min(items.size() - 2 * offset, Math.max(0, result));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fling(int velocityY) {
|
||||
super.fling(velocityY / 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (ev.getAction() == MotionEvent.ACTION_UP) {
|
||||
|
||||
startScrollerTask();
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
|
||||
private OnIndoorFloorListener onIndoorFloorSwtichListener;
|
||||
|
||||
public OnIndoorFloorListener getOnIndoorFloorListener() {
|
||||
return onIndoorFloorSwtichListener;
|
||||
}
|
||||
|
||||
public void setOnIndoorFloorListener(
|
||||
OnIndoorFloorListener onIndoorFloorSwtichListener) {
|
||||
this.onIndoorFloorSwtichListener = onIndoorFloorSwtichListener;
|
||||
}
|
||||
|
||||
public static abstract interface OnIndoorFloorListener {
|
||||
public abstract void onSelected(int selectedIndex);
|
||||
}
|
||||
|
||||
// utils
|
||||
public static int dip2px(Context context, float dpValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dpValue * scale + 0.5f);
|
||||
}
|
||||
|
||||
public static int px2dip(Context context, float pxValue) {
|
||||
final float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (pxValue / scale + 0.5f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取控件的高度,如果获取的高度为0,则重新计算尺寸后再返回高度
|
||||
*
|
||||
* @param view
|
||||
* @return
|
||||
*/
|
||||
public static int getViewMeasuredHeight(View view) {
|
||||
calcViewMeasure(view);
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取控件的宽度,如果获取的宽度为0,则重新计算尺寸后再返回宽度
|
||||
*
|
||||
* @param view
|
||||
* @return
|
||||
*/
|
||||
public static int getViewMeasuredWidth(View view) {
|
||||
calcViewMeasure(view);
|
||||
return view.getMeasuredWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测量控件的尺寸
|
||||
*
|
||||
* @param view
|
||||
*/
|
||||
public static void calcViewMeasure(View view) {
|
||||
|
||||
int width = MeasureSpec.makeMeasureSpec(0,
|
||||
MeasureSpec.UNSPECIFIED);
|
||||
int expandSpec = MeasureSpec.makeMeasureSpec(
|
||||
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
|
||||
view.measure(width, expandSpec);
|
||||
}
|
||||
|
||||
public void setVisible(boolean isEnable) {
|
||||
if (isEnable) {
|
||||
if(!isVisible()) {
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
} else {
|
||||
if(isVisible())
|
||||
setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return getVisibility() == VISIBLE ? true : false;
|
||||
}
|
||||
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.IndoorBuilding;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.IndoorInfo;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.IndoorLevel;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MapPoi;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem;
|
||||
import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager;
|
||||
import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm;
|
||||
import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IndoorMapActivity extends AppCompatActivity implements TencentMap.OnIndoorStateChangeListener {
|
||||
|
||||
private static final String TAG = "IndoorMapActivity";
|
||||
private MapView mapView;
|
||||
private TencentMap tencentMap;
|
||||
private IndoorFloorView indoorFloorView;
|
||||
private UiSettings uiSettings;
|
||||
private Handler handler = new Handler();
|
||||
private String floorName;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_indoor);
|
||||
mapView = findViewById(R.id.mapView);
|
||||
indoorFloorView = findViewById(R.id.indoor_floor);
|
||||
if (tencentMap == null) {
|
||||
tencentMap = mapView.getMap();
|
||||
}
|
||||
//欧美汇室内地图,需Key开通室内地图权限
|
||||
CameraUpdate camera =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(39.979382, 116.314106),
|
||||
18,
|
||||
0f,
|
||||
0f));
|
||||
tencentMap.moveCamera(camera);
|
||||
final ArrayList<MarkerCluster> markerClusters = new ArrayList<>();
|
||||
|
||||
uiSettings = tencentMap.getUiSettings();
|
||||
tencentMap.setIndoorEnabled(true);
|
||||
//设置室内蒙层颜色 sdk版本4.3.5新增接口
|
||||
tencentMap.setIndoorMaskColor(R.color.color_C71585);
|
||||
//设置室内图状态变化监听
|
||||
tencentMap.setOnIndoorStateChangeListener(this);
|
||||
tencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
|
||||
//设置是否隐藏楼层控件
|
||||
uiSettings.setIndoorLevelPickerEnabled(false);
|
||||
indoorFloorView.setOnIndoorFloorListener(new MyIndoorViewAdapter());
|
||||
ClusterManager<MarkerCluster> markerClusterClusterManager = new ClusterManager<MarkerCluster>(this, tencentMap);
|
||||
NonHierarchicalDistanceBasedAlgorithm<MarkerCluster> nba = new NonHierarchicalDistanceBasedAlgorithm<>(this);
|
||||
nba.setMaxDistanceAtZoom(15);
|
||||
markerClusterClusterManager.setAlgorithm(nba);
|
||||
DefaultClusterRenderer<MarkerCluster> renderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterClusterManager);
|
||||
renderer.setMinClusterSize(2);
|
||||
renderer.setBuckets(new int[]{5, 10, 20});
|
||||
markerClusterClusterManager.setRenderer(renderer);
|
||||
//添加室内图marker
|
||||
tencentMap.setOnMapPoiClickListener(new TencentMap.OnMapPoiClickListener() {
|
||||
@Override
|
||||
public void onClicked(MapPoi mapPoi) {
|
||||
LatLng position = mapPoi.getPosition();
|
||||
MarkerOptions markerOptions = new MarkerOptions().position(position).title(mapPoi.name).infoWindowEnable(true);
|
||||
if (!TextUtils.isEmpty("F3")) {
|
||||
markerOptions.indoorInfo(new IndoorInfo("11000023805", "F3"));
|
||||
|
||||
}
|
||||
Marker marker = tencentMap.addMarker(markerOptions);
|
||||
LatLng position1 = mapPoi.getPosition();
|
||||
markerClusters.add(new MarkerCluster(position1.getLatitude(), position1.getLongitude()));
|
||||
|
||||
}
|
||||
});
|
||||
tencentMap.setOnCameraChangeListener(markerClusterClusterManager);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onIndoorBuildingFocused() {
|
||||
Log.d(TAG, "onIndoorBuildingFocused: 室内图场景激活回调");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onIndoorLevelActivated(final IndoorBuilding indoorBuilding) {
|
||||
if (indoorBuilding != null) {
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
indoorFloorView.setVisible(true);
|
||||
if (mIndoorBuilding == null || !mIndoorBuilding.getBuidlingId().equals(indoorBuilding.getBuidlingId())) {
|
||||
List<IndoorLevel> levels = indoorBuilding.getLevels();
|
||||
String[] activedIndoorFloorNames1 = tencentMap.getActivedIndoorFloorNames();
|
||||
indoorFloorView.setItems(activedIndoorFloorNames1);
|
||||
for (int i = 0; i < levels.size(); i++) {
|
||||
floorName = levels.get(i).getName();
|
||||
indoorFloorView.setSeletion(floorName);
|
||||
}
|
||||
}
|
||||
mIndoorBuilding = indoorBuilding;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
indoorFloorView.setVisible(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onIndoorBuildingDeactivated() {
|
||||
Log.d(TAG, "onIndoorBuildingDeactivated: 当前室内图处于无效状态");
|
||||
return false;
|
||||
}
|
||||
|
||||
IndoorBuilding mIndoorBuilding = null;
|
||||
|
||||
private class MyIndoorViewAdapter implements IndoorFloorView.OnIndoorFloorListener {
|
||||
|
||||
@Override
|
||||
public void onSelected(int selectedIndex) {
|
||||
if (mIndoorBuilding != null) {
|
||||
|
||||
List<IndoorLevel> levels = mIndoorBuilding.getLevels();
|
||||
String activedIndoorFloorName = tencentMap.getActivedIndoorFloorNames()[selectedIndex];
|
||||
String name = levels.get(selectedIndex).getName();
|
||||
name = activedIndoorFloorName;
|
||||
String buidlingId = mIndoorBuilding.getBuidlingId();
|
||||
tencentMap.setIndoorFloor(buidlingId, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MarkerCluster implements ClusterItem {
|
||||
|
||||
private final LatLng latLng;
|
||||
|
||||
public MarkerCluster(double lat, double longitude) {
|
||||
latLng = new LatLng(lat, longitude);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LatLng getPosition() {
|
||||
|
||||
return latLng;
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapRenderLayer;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
|
||||
|
||||
public class MapRenderLayerActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener {
|
||||
|
||||
private TextureView textureView;
|
||||
private MapRenderLayer mapRenderLayer;
|
||||
private TencentMap tencentMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map_render_layer);
|
||||
textureView = findViewById(R.id.textureView);
|
||||
textureView.setOpaque(false);
|
||||
textureView.setSurfaceTextureListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
|
||||
TencentMapOptions mapOptions = new TencentMapOptions();
|
||||
// mapOptions.setMapKey("");
|
||||
mapOptions.setExtSurface(surface);
|
||||
mapOptions.setExtSurfaceDimension(width, height);
|
||||
mapRenderLayer = new MapRenderLayer(this, mapOptions);
|
||||
// mapRenderLayer.onResume();
|
||||
textureView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
mapRenderLayer.onTouchEvent(event);
|
||||
mapRenderLayer.dispatchTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
tencentMap = mapRenderLayer.getMap();
|
||||
tencentMap.setMapStyle(3);
|
||||
UiSettings uiSettings = tencentMap.getUiSettings();
|
||||
uiSettings.setAllGesturesEnabled(true);
|
||||
tencentMap.moveCamera(CameraUpdateFactory.zoomTo(8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onSurfaceChanged(surface, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onDestroy();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onStart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onRestart();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mapRenderLayer != null) {
|
||||
mapRenderLayer.onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
/**
|
||||
* Demonstrates the different base layers of a map.
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
public class MapStyleDemoActivity extends FragmentActivity implements TencentMap.OnCameraChangeListener {
|
||||
private MapView mMapView;
|
||||
private TextView mTextView;
|
||||
private TencentMap mTencentMap;
|
||||
private Switch mSwitch;
|
||||
private Spinner mSpinner;
|
||||
|
||||
private String[] styles = new String[]{"style1", "style2", "style3", "style4", "style5",
|
||||
"normal", "traffic_navi", "traffic_navi_night", "satellite", "night", "navi", "night", "eagle_day", "eagle_night"};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map_style);
|
||||
mMapView = findViewById(R.id.map_view);
|
||||
mTextView = findViewById(R.id.tv_level);
|
||||
mSwitch=findViewById(R.id.switch_open);
|
||||
mTencentMap = mMapView.getMap();
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.901268, 116.403854), 11f, 0f, 0f));
|
||||
mTencentMap.moveCamera(cameraUpdate);
|
||||
//mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(39.901268, 116.403854))); //移动地图
|
||||
mTencentMap.setOnCameraChangeListener(this);
|
||||
mSpinner = findViewById(R.id.sp_style);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles);
|
||||
mSpinner.setAdapter(adapter);
|
||||
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (position < 5) {
|
||||
mTencentMap.setMapStyle(position + 1);
|
||||
}
|
||||
switch (position) {
|
||||
case 5:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NORMAL);
|
||||
break;
|
||||
case 6:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NAVI);
|
||||
break;
|
||||
case 7:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NIGHT);
|
||||
break;
|
||||
case 8:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_SATELLITE);
|
||||
break;
|
||||
case 9:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NIGHT);
|
||||
break;
|
||||
case 10:
|
||||
mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NAVI);
|
||||
break;
|
||||
case 11:
|
||||
mTencentMap.setMapStyle(13 + 1000);
|
||||
break;
|
||||
case 12:
|
||||
mTencentMap.setMapStyle(14 + 1000);
|
||||
break;
|
||||
case 13:
|
||||
mTencentMap.setMapStyle(15 + 1000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
RadioGroup rg = findViewById(R.id.rg_map_type);
|
||||
rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
switch (checkedId) {
|
||||
case R.id.rb_normal_type:
|
||||
if (mTencentMap != null) {
|
||||
mTencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL);
|
||||
}
|
||||
break;
|
||||
case R.id.rb_dark_type:
|
||||
if (mTencentMap != null) {
|
||||
mTencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
|
||||
}
|
||||
break;
|
||||
case R.id.rb_sagellite_type:
|
||||
if (mTencentMap != null) {
|
||||
mTencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
mTencentMap.getUiSettings().setCompassEnabled(true);
|
||||
mTencentMap.getUiSettings().setMyLocationButtonEnabled(true);
|
||||
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
PorterDuff.Mode buttonTintMode = compoundButton.getButtonTintMode();
|
||||
if(b){
|
||||
mTencentMap.setBuildingEnable(true);
|
||||
}else{
|
||||
mTencentMap.setBuildingEnable(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
Log.i("TAG","地图滑动了");
|
||||
mTextView.setText("当前缩放级别为:" + cameraPosition.zoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinished(CameraPosition cameraPosition) {
|
||||
Log.i("TAG","地图滑动了");
|
||||
mTextView.setText("当前缩放级别为:" + cameraPosition.zoom);
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.heatoverlay.ScatterPlotOverlayActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TextureMapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class MapViewActivity extends AppCompatActivity {
|
||||
|
||||
/**
|
||||
* 由于SDK并没有提供用于MapView管理地图生命周期的Activity
|
||||
* 因此需要用户继承Activity后管理地图的生命周期,防止内存泄露
|
||||
*/
|
||||
|
||||
private TextureMapView mapView;
|
||||
protected TencentMap tencentMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_map_view);
|
||||
|
||||
mapView = findViewById(R.id.mapview);
|
||||
mapView.setOpaque(false);
|
||||
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
||||
tencentMap = mapView.getMap();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* mapview的生命周期管理
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
mapView.onRestart();
|
||||
}
|
||||
}
|
@ -1,559 +0,0 @@
|
||||
//package com.tencent.map.vector.demo.basic;
|
||||
//
|
||||
//import androidx.annotation.NonNull;
|
||||
//import androidx.annotation.Nullable;
|
||||
//import androidx.appcompat.app.AppCompatActivity;
|
||||
//import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
//import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
//import androidx.recyclerview.widget.RecyclerView;
|
||||
//
|
||||
//import android.content.BroadcastReceiver;
|
||||
//import android.content.Context;
|
||||
//import android.content.Intent;
|
||||
//import android.content.IntentFilter;
|
||||
//import android.net.ConnectivityManager;
|
||||
//import android.net.NetworkInfo;
|
||||
//import android.os.Build;
|
||||
//import android.os.Bundle;
|
||||
//import android.os.Handler;
|
||||
//import android.os.Message;
|
||||
//import android.util.Log;
|
||||
//import android.view.LayoutInflater;
|
||||
//import android.view.Menu;
|
||||
//import android.view.MenuItem;
|
||||
//import android.view.View;
|
||||
//import android.view.ViewGroup;
|
||||
//import android.widget.Button;
|
||||
//import android.widget.LinearLayout;
|
||||
//import android.widget.TextView;
|
||||
//import android.widget.Toast;
|
||||
//
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineItem;
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineItemController;
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineMapComponent;
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineMapSyncedListener;
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineStatus;
|
||||
//import com.tencent.map.sdk.comps.offlinemap.OfflineStatusChangedListener;
|
||||
//import cc.winboll.studio.positions.R;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
||||
//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * 离线地图下载、取消下载、删除
|
||||
// */
|
||||
//public class OfflineMapActivity extends AppCompatActivity {
|
||||
// private static final String TAG = "OfflineMapActivity";
|
||||
// private Button btnGoWork;
|
||||
// private Button btnZoomIn;
|
||||
// private Button btnZoomOut;
|
||||
// private Button btnReboot;
|
||||
// private Button btnSync;
|
||||
// private Button btnRefresh;
|
||||
// private MapView mapView;
|
||||
// private RecyclerView offlineItemRecycleView;
|
||||
//
|
||||
// private TencentMap map;
|
||||
// private OfflineMapComponent offlineComp;
|
||||
//
|
||||
// private OfflineAdapter offlineAdapter;
|
||||
//
|
||||
// private List<OfflineItem> offlineItems = new ArrayList<>();
|
||||
//
|
||||
// private IntentFilter intentFilter;
|
||||
// private NetworkChangeReceiver networkChangeReceiver;
|
||||
// private ConnectivityManager connectivityManager;
|
||||
// private TextView tvParmes;
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// setContentView(R.layout.activity_offline_map);
|
||||
// btnGoWork = findViewById(R.id.btn_go_work);
|
||||
// btnZoomIn = findViewById(R.id.btn_zoom_in);
|
||||
// btnZoomOut = findViewById(R.id.btn_zoom_out);
|
||||
// btnReboot = findViewById(R.id.btn_reboot_map);
|
||||
// btnSync = findViewById(R.id.btn_sync);
|
||||
// btnRefresh = findViewById(R.id.btn_refresh);
|
||||
// mapView = findViewById(R.id.map_view);
|
||||
// tvParmes = findViewById(R.id.tv_parmes);
|
||||
// offlineItemRecycleView = findViewById(R.id.offline_item_list);
|
||||
// connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
//
|
||||
// initMap();
|
||||
// //重置地图
|
||||
// btnReboot.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (map != null) {
|
||||
// mapView.onPause();
|
||||
// mapView.onStop();
|
||||
// mapView.onDestroy();
|
||||
// map = null;
|
||||
// initMap();
|
||||
// mapView.onStart();
|
||||
// mapView.onResume();
|
||||
// tvParmes.setText("重置地图");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// offlineAdapter = new OfflineAdapter(offlineItems);
|
||||
// offlineItemRecycleView.setLayoutManager(new LinearLayoutManager(this));
|
||||
// offlineItemRecycleView.setAdapter(offlineAdapter);
|
||||
// offlineItemRecycleView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
|
||||
// intentFilter = new IntentFilter();
|
||||
// intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||
// networkChangeReceiver = new NetworkChangeReceiver();
|
||||
// }
|
||||
//
|
||||
// private void initMap() {
|
||||
// // 设置离线地图
|
||||
// TencentMapOptions options = new TencentMapOptions();
|
||||
// options.setOfflineMapEnable(true);
|
||||
//
|
||||
// map = mapView.getMap(options);
|
||||
//
|
||||
// map.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() {
|
||||
// @Override
|
||||
// public void onMapLoaded() {
|
||||
// Toast.makeText(OfflineMapActivity.this, "地图加载完成", Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
// });
|
||||
// //获取离线地图的城市列表
|
||||
// offlineComp = map.getMapComponent(OfflineMapComponent.class);
|
||||
//
|
||||
// Log.d(TAG, "Offline enable:" + offlineComp.isOfflineMapEnable());
|
||||
//
|
||||
// // 回公司按钮
|
||||
// btnGoWork.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// List<LatLng> latLngs = new ArrayList<>();
|
||||
// latLngs.add(new LatLng(40.042893, 116.269673));
|
||||
// latLngs.add(new LatLng(40.038951, 116.275241));
|
||||
// LatLng center = new LatLng(40.040429, 116.273525);
|
||||
// map.addMarker(new MarkerOptions(center)
|
||||
// .anchor(0.5f, 1));
|
||||
// map.moveCamera(CameraUpdateFactory.newLatLngBoundsWithMapCenter(
|
||||
// new LatLngBounds.Builder()
|
||||
// .include(latLngs)
|
||||
// .build(),
|
||||
// center,
|
||||
// 100));
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 地图放大按钮
|
||||
// btnZoomIn.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// map.moveCamera(CameraUpdateFactory.zoomIn());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 地图缩小按钮
|
||||
// btnZoomOut.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// map.moveCamera(CameraUpdateFactory.zoomOut());
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 同步离线地图信息按钮
|
||||
// btnSync.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// syncData();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // 刷新离线地图列表按钮
|
||||
// btnRefresh.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// offlineItemRecycleView.setVisibility(View.VISIBLE);
|
||||
// refreshOfflineList();
|
||||
// }
|
||||
// });
|
||||
// map.moveCamera(CameraUpdateFactory.zoomTo(5)); // 设置缩放级别,显示全国概略图.
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onStart() {
|
||||
// super.onStart();
|
||||
// mapView.onStart();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
// mapView.onResume();
|
||||
// registerReceiver(networkChangeReceiver, intentFilter);
|
||||
//
|
||||
//// offlineItems.addAll(offlineComp.getOfflineItemList());
|
||||
//// tryToOpenOffline();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onPause() {
|
||||
// super.onPause();
|
||||
// mapView.onPause();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onStop() {
|
||||
// super.onStop();
|
||||
// mapView.onStop();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onDestroy() {
|
||||
// super.onDestroy();
|
||||
// mapView.onDestroy();
|
||||
// }
|
||||
//
|
||||
// private class OfflineAdapter extends RecyclerView.Adapter<OfflineAdapter.OfflineViewHolder> {
|
||||
//
|
||||
// List<OfflineItem> offlineItems;
|
||||
//
|
||||
// OfflineAdapter(List<OfflineItem> offlineItems) {
|
||||
// this.offlineItems = offlineItems;
|
||||
// }
|
||||
//
|
||||
// @NonNull
|
||||
// @Override
|
||||
// public OfflineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
// View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_offline
|
||||
// , parent, false);
|
||||
// return new OfflineViewHolder(view);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBindViewHolder(@NonNull OfflineViewHolder holder, int position) {
|
||||
// final OfflineItem offlineItem = offlineItems.get(position);
|
||||
//
|
||||
// final OfflineItemController cityController =
|
||||
// offlineComp.getOfflineItemController(offlineItem, statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// holder.tvTitle.setText("【controller is null】" + offlineItem.toString());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// holder.tvTitle.setText(offlineItem.toString());
|
||||
//
|
||||
// holder.btnSwitch.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// boolean isClosed = cityController.close();
|
||||
// if (isClosed) {
|
||||
// // toast("已关闭【" + offlineItem.getName() + "】的离线地图");
|
||||
// tvParmes.setText("已关闭【" + offlineItem.getName() + "】的离线地图");
|
||||
//
|
||||
// }
|
||||
// Log.d(TAG, offlineItem.getName() + " close offline:" + isClosed);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// holder.btnDownload.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// downloadOffline(offlineItem);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// holder.btnDelete.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// boolean isDeleted = cityController.removeCache();
|
||||
// if (isDeleted) {
|
||||
// // toast("缓存移除成功");
|
||||
// tvParmes.setText("缓存移除成功");
|
||||
// } else {
|
||||
// // toast("缓存移除失败");
|
||||
// tvParmes.setText("缓存移除失败");
|
||||
// }
|
||||
// Log.d(TAG, offlineItem.getName() + " remove cache:" + isDeleted);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemCount() {
|
||||
// return offlineItems.size();
|
||||
// }
|
||||
//
|
||||
// class OfflineViewHolder extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// TextView tvTitle;
|
||||
// Button btnSwitch;
|
||||
// Button btnDownload;
|
||||
// Button btnDelete;
|
||||
//
|
||||
// public OfflineViewHolder(@NonNull View itemView) {
|
||||
// super(itemView);
|
||||
// tvTitle = itemView.findViewById(R.id.tv_offline_title);
|
||||
// btnSwitch = itemView.findViewById(R.id.btn_switch_offline);
|
||||
// btnDownload = itemView.findViewById(R.id.btn_download_offline);
|
||||
// btnDelete = itemView.findViewById(R.id.btn_delete_offline);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// OfflineStatusChangedListener statusChangedListener = new OfflineStatusChangedListener() {
|
||||
// @Override
|
||||
// public void onStatusChanged(OfflineItem offlineItem, OfflineStatus offlineStatus) {
|
||||
// Log.d(TAG, offlineItem.getName() + " onStatusChanged: " + offlineStatus);
|
||||
// final Message msg = new Message();
|
||||
// msg.obj = offlineItem;
|
||||
// switch (offlineStatus) {
|
||||
// case OPEN: //开始离线
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// msg.what = STATE_OPEN;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// }).start();
|
||||
// break;
|
||||
// case CLOSE: //关闭离线
|
||||
// break;
|
||||
// case COMPLETED: //完成下载
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// msg.what = STATE_COMPLETED;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// }).start();
|
||||
// if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("china2")) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
|
||||
// statusChangedListener);
|
||||
// cityController.open();
|
||||
// map.moveCamera(CameraUpdateFactory.zoomTo(5)); // 设置缩放级别,显示全国概略图.
|
||||
// } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("beijingshi")) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
|
||||
// statusChangedListener);
|
||||
// cityController.open();
|
||||
// map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.909018, 116.397427), 16));
|
||||
// } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("shanghaishi")) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
|
||||
// statusChangedListener);
|
||||
// cityController.open();
|
||||
// map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(31.230378, 121.473658), 16));
|
||||
// } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("tianjinshi")) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
|
||||
// statusChangedListener);
|
||||
// cityController.open();
|
||||
// map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.085294, 117.201538), 16));
|
||||
// } else {
|
||||
// toast("可参考demo自行移动视野范围");
|
||||
// }
|
||||
// break;
|
||||
// case CANCEL: //取消下载
|
||||
// toast("取消下载");
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// msg.what = STATE_CANCEL;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// }).start();
|
||||
// break;
|
||||
// case DOWNLOADING: //下载中
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// msg.what = STATE_DOWNLOAD;
|
||||
// mHandler.sendMessage(msg);
|
||||
// }
|
||||
// }).start();
|
||||
// break;
|
||||
// case ERROR: //离线错误
|
||||
// toast("离线错误");
|
||||
// break;
|
||||
// case READY: //准备下载
|
||||
// toast("准备下载");
|
||||
// break;
|
||||
// case START: //开始下载
|
||||
// msg.what = STATE_START;
|
||||
// mHandler.sendMessage(msg);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// private void refreshOfflineList() {
|
||||
// //获取离线地图列表
|
||||
// List<OfflineItem> offlineItems = offlineComp.getOfflineItemList();
|
||||
// Log.d(TAG, "Offline Items num:" + offlineItems.size());
|
||||
//// for (OfflineItem item : offlineItems) {
|
||||
//// Log.d(TAG, item.toString());
|
||||
//// }
|
||||
//
|
||||
// this.offlineItems.clear();
|
||||
// this.offlineItems.addAll(offlineItems);
|
||||
// offlineAdapter.notifyDataSetChanged();
|
||||
// toast("刷新离线地图列表");
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void tryToOpenOffline() {
|
||||
// // 无网情况主动开启离线地图
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
// if (connectivityManager.getActiveNetwork() == null) {
|
||||
// Log.d(TAG, "tryToOpenOffline: 无网络,尝试开启离线地图,item size:" + offlineItems.size());
|
||||
// for (OfflineItem item : offlineItems) {
|
||||
// if (item.getPercentage() == 100 && item.getPinyin().equals("beijingshi")) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(item,
|
||||
// statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// Log.d(TAG, item.getName() + "try: controller is null");
|
||||
// } else {
|
||||
// Log.d(TAG, item.getName() + "try: openOffline: " + cityController.open());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// toast("require API > M(23)");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void closeOffline() {
|
||||
// List<OfflineItem> items = offlineComp.getOfflineItemList();
|
||||
// Log.d(TAG, "closeOffline: ,item size:" + items.size());
|
||||
// for (OfflineItem item : items) {
|
||||
// if (item.getPercentage() == 100) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(item,
|
||||
// statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// Log.d(TAG, item.getName() + "close: controller is null");
|
||||
// } else {
|
||||
// Log.d(TAG, item.getName() + "close: close Offline: " + cityController.close());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void syncData() {
|
||||
// //同步最新数据
|
||||
// offlineComp.syncLatestData(new OfflineMapSyncedListener() {
|
||||
// @Override
|
||||
// public void onSynced(boolean b) {
|
||||
// Log.d(TAG, "onSynced: " + b);
|
||||
// refreshOfflineList();
|
||||
// // tryToOpenOffline();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void downloadOffline(OfflineItem offlineItem) {
|
||||
// //获取某一Item的离线地图数据
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem, statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// Toast.makeText(this, "cityController为NULL", Toast.LENGTH_SHORT).show();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// boolean needDownload = cityController.checkInvalidate();
|
||||
// Log.d(TAG, "need download:" + cityController.checkInvalidate());
|
||||
// if (needDownload) {
|
||||
// //执行下载
|
||||
// cityController.startDownload();
|
||||
// tvParmes.setText("开始下载【" + offlineItem.getName() + "】的离线地图");
|
||||
// } else {
|
||||
// //跳过更新,打开离线
|
||||
// boolean isOpened = cityController.open();
|
||||
// if (isOpened) {
|
||||
// tvParmes.setText("已开启【" + offlineItem.getName() + "】的离线地图");
|
||||
// }
|
||||
// Log.d(TAG, offlineItem.getName() + " open offline:" + isOpened);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private final class NetworkChangeReceiver extends BroadcastReceiver {
|
||||
// @Override
|
||||
// public void onReceive(Context context, Intent intent) {
|
||||
// NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
// //获取离线那地图列表
|
||||
// List<OfflineItem> items = offlineComp.getOfflineItemList();
|
||||
// Log.d(TAG, "onReceive: 网络状态变化, offline item size:" + items.size());
|
||||
// if (networkInfo != null) {
|
||||
// Toast.makeText(context, "当前无网络连接", Toast.LENGTH_SHORT).show();
|
||||
// for (OfflineItem item : items) {
|
||||
// if (item.getPercentage() == 100) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(item,
|
||||
// statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// Log.d(TAG, item.getName() + " controller is null");
|
||||
// } else {
|
||||
// Log.d(TAG, item.getName() + " closeOffline: " + cityController.close());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // 加载所有已下载的离线地图
|
||||
// items = offlineComp.getOfflineItemList();
|
||||
// for (OfflineItem item : items) {
|
||||
// if (item.getPercentage() == 100) {
|
||||
// OfflineItemController cityController = offlineComp.getOfflineItemController(item,
|
||||
// statusChangedListener);
|
||||
// if (cityController == null) {
|
||||
// Log.d(TAG, item.getName() + " controller is null");
|
||||
// } else {
|
||||
// Log.d(TAG, item.getName() + " openOffline: " + cityController.open());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private final int STATE_DOWNLOAD = 1;
|
||||
// private final int STATE_COMPLETED = 2;
|
||||
// private final int STATE_OPEN = 3;
|
||||
// private final int STATE_CANCEL = 4;
|
||||
// private final int STATE_START = 5;
|
||||
//
|
||||
// private Handler mHandler = new Handler() {
|
||||
// public void handleMessage(Message msg) {
|
||||
// OfflineItem item = (OfflineItem) msg.obj;
|
||||
// switch (msg.what) {
|
||||
// case STATE_DOWNLOAD:
|
||||
// if (item.getPercentage() % 10 == 0) {
|
||||
// tvParmes.setText("正在下载【" + item.getName() + "】离线地图:" + item.getPercentage() + "%");
|
||||
// Log.d("getPercentage", item.getPercentage() + "");
|
||||
// }
|
||||
// break;
|
||||
// case STATE_COMPLETED:
|
||||
// tvParmes.setText(item.getName() + "离线地图下载结束");
|
||||
// break;
|
||||
// case STATE_OPEN:
|
||||
// tvParmes.setText(item.getName() + "离线地图已开启 ");
|
||||
// break;
|
||||
// case STATE_CANCEL:
|
||||
// break;
|
||||
// case STATE_START:
|
||||
// tvParmes.setText(item.getName() + "离线地图开始下载,点击刷新列表查看进度");
|
||||
// break;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// private void toast(String msg) {
|
||||
// Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
|
||||
// }
|
||||
//
|
||||
//}
|
@ -1,91 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapContext;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Language;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.OverSeaTileProvider;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
public class OverseaMapActivity extends SupportMapFragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
//纽约时代广场海外地图,需Key开通海外位置服务权限
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(40.75797, -73.985542),
|
||||
11,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
//设置自定义海外图源
|
||||
tencentMap.setOverSeaTileProvider(new CustomOverSeaTileProvider(tencentMap.getMapContext()));
|
||||
}
|
||||
|
||||
class CustomOverSeaTileProvider extends OverSeaTileProvider {
|
||||
boolean mIsZhLanguage;
|
||||
boolean mIsNight;
|
||||
|
||||
/**
|
||||
* 创建海外图源供应
|
||||
*/
|
||||
public CustomOverSeaTileProvider(TencentMapContext context){
|
||||
//设置名称和版本号
|
||||
super("custom", 1, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getTileUrl(int x, int y, int zoom) {
|
||||
String url = "https://xxxx.com/x=%d&y=%d&z=%d&s=%s&l=&s";
|
||||
String formatUrl = String.format(Locale.ENGLISH, url, x, y, zoom, mIsNight ? "dark" : "day", mIsZhLanguage ? "zh" : "en");
|
||||
try {
|
||||
return new URL(formatUrl);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDayNightChange(boolean dayNight) {
|
||||
mIsNight = dayNight;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onLanguageChange(Language language) {
|
||||
mIsZhLanguage = (language == Language.zh);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getLogo(boolean isNight) {
|
||||
AssetManager assetManager = getAssets();
|
||||
Bitmap iBitmap = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
is = assetManager.open("logo.png");
|
||||
iBitmap = BitmapFactory.decodeStream(is);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
} catch (OutOfMemoryError ignored) {
|
||||
} finally {
|
||||
// IO.safeClose(is);
|
||||
}
|
||||
return iBitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,135 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class RecyclerListActivity extends FragmentActivity {
|
||||
|
||||
private static final String TAG = "RecyclerListActivity";
|
||||
|
||||
RecyclerView recyclerView;
|
||||
private MapViewAdapter mapViewAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_recycler_list);
|
||||
recyclerView = findViewById(R.id.rv_container);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
|
||||
mapViewAdapter = new MapViewAdapter(this);
|
||||
recyclerView.setAdapter(mapViewAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (recyclerView != null) {
|
||||
recyclerView.setAdapter(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MapViewHolder extends RecyclerView.ViewHolder {
|
||||
MapView mMapView;
|
||||
|
||||
public MapViewHolder(@NonNull View itemView, MapView mapView) {
|
||||
super(itemView);
|
||||
mMapView = mapView;
|
||||
}
|
||||
|
||||
public void onRecycle() {
|
||||
if (mMapView != null) {
|
||||
mMapView.onPause();
|
||||
mMapView.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
public void onBind() {
|
||||
if (mMapView != null) {
|
||||
mMapView.onResume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MapViewAdapter extends RecyclerView.Adapter<MapViewHolder> {
|
||||
private List<MapView> mMapViews;
|
||||
private static final int COUNT = 15;
|
||||
private Context mContext;
|
||||
|
||||
public MapViewAdapter(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
mMapViews = new LinkedList<>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MapViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, final int type) {
|
||||
|
||||
FrameLayout mapContainer = new FrameLayout(mContext);
|
||||
if (type == 1) {
|
||||
TencentMapOptions tencentMapOptions = new TencentMapOptions();
|
||||
tencentMapOptions.setDisallowInterceptTouchEvent(true);
|
||||
MapView mapView = new MapView(mContext, tencentMapOptions);
|
||||
mapView.setId(View.NO_ID);
|
||||
mapView.setLayoutParams(new FrameLayout.LayoutParams(1000, 700));
|
||||
mapContainer.addView(mapView);
|
||||
|
||||
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.CENTER;
|
||||
return new MapViewHolder(mapContainer, mapView);
|
||||
} else {
|
||||
return new MapViewHolder(mapContainer, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MapViewHolder mapViewHolder, int i) {
|
||||
mapViewHolder.onBind();
|
||||
if (mapViewHolder.mMapView != null) {
|
||||
mMapViews.add(mapViewHolder.mMapView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
|
||||
if (position % 3 == 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull MapViewHolder holder) {
|
||||
|
||||
holder.onRecycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
for (MapView mapView : mMapViews) {
|
||||
mapView.onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
|
||||
|
||||
public class SetMapTypeActivity extends SupportMapFragmentActivity implements RadioGroup.OnCheckedChangeListener {
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
radioGroup = findViewById(R.id.lay_map_type);
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
radioGroup.setOnCheckedChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
||||
switch (i) {
|
||||
case R.id.btn_normal: //普通地图-默认地图类型
|
||||
tencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL);
|
||||
break;
|
||||
case R.id.btn_satellite: //卫星地图
|
||||
tencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE);
|
||||
break;
|
||||
case R.id.btn_dark: //暗色地图
|
||||
tencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
|
||||
break;
|
||||
case R.id.btn_traffic:
|
||||
tencentMap.setTrafficEnabled(true);
|
||||
break;
|
||||
case R.id.style_map:
|
||||
/*TencentMapOptions mapOptions = new TencentMapOptions();
|
||||
//将本地资源打包到apk的asset目录中
|
||||
mapOptions.setCustomAssetsPath("myMapStyle");
|
||||
//参数1对应的是“我的样式”中的序号
|
||||
tencentMap.setMapStyle(1);
|
||||
MapView mMapView = new MapView(SetMapTypeActivity.this, mapOptions);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.SupportMapFragment;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.UiSettings;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class SupportMapFragmentActivity extends AppCompatActivity {
|
||||
|
||||
/**
|
||||
* SDK提供了SupportMapFragment这个类来加载地图,这个类的方便之处就在于不用手动管理内存
|
||||
*/
|
||||
|
||||
private FragmentManager fm;
|
||||
protected TencentMap tencentMap;
|
||||
private SupportMapFragment supportMapFragment;
|
||||
protected UiSettings mapUiSettings;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_support_map_fragment);
|
||||
|
||||
//创建tencentMap地图对象,可以完成对地图的几乎所有操作
|
||||
fm = getSupportFragmentManager();
|
||||
supportMapFragment = (SupportMapFragment) fm.findFragmentById(R.id.map_frag);
|
||||
tencentMap = supportMapFragment.getMap();
|
||||
mapUiSettings = tencentMap.getUiSettings();
|
||||
//对地图操作类进行操作
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(39.984066, 116.307548),
|
||||
15,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package com.tencent.map.vector.demo.basic;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
|
||||
public class UiSettingsActivity extends SupportMapFragmentActivity {
|
||||
|
||||
|
||||
private Switch logoControl;
|
||||
private Switch compassControl;
|
||||
private Switch scaleViewControl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
}
|
||||
private void initView(){
|
||||
|
||||
logoControl = findViewById(R.id.switch_logo);
|
||||
compassControl = findViewById(R.id.switch_compass);
|
||||
scaleViewControl = findViewById(R.id.switch_scale_view);
|
||||
logoControl.setVisibility(View.VISIBLE);
|
||||
logoControl.setText("logo位置");
|
||||
compassControl.setVisibility(View.VISIBLE);
|
||||
compassControl.setText("指南针");
|
||||
scaleViewControl.setVisibility(View.VISIBLE);
|
||||
scaleViewControl.setText("比例尺");
|
||||
|
||||
//打开缩放
|
||||
mapUiSettings.setZoomControlsEnabled(true);
|
||||
//打开位置标志
|
||||
mapUiSettings.setMyLocationButtonEnabled(true);
|
||||
|
||||
|
||||
logoControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
//logo左下角
|
||||
mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
||||
}else{
|
||||
//logo右上角
|
||||
mapUiSettings.setLogoPosition(TencentMapOptions.LOGO_POSITION_TOP_RIGHT);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
compassControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
//显示指南针
|
||||
mapUiSettings.setCompassEnabled(true);
|
||||
}else{
|
||||
//隐藏指南针
|
||||
mapUiSettings.setCompassEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
scaleViewControl.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
//打开比例尺
|
||||
mapUiSettings.setScaleViewEnabled(true);
|
||||
}else{
|
||||
//关闭比例尺
|
||||
mapUiSettings.setScaleViewEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.tencent.map.vector.demo.camera;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.Projection;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion;
|
||||
|
||||
public class MapAnchorZoomActivity extends SupportMapFragmentActivity {
|
||||
private Marker marker;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
LatLng latLng = new LatLng(39.984108,116.307557);
|
||||
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
latLng,
|
||||
15,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
Projection projection = tencentMap.getProjection();
|
||||
|
||||
VisibleRegion region = projection.getVisibleRegion();
|
||||
|
||||
tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_HEIGHT);
|
||||
tencentMap.setRestrictBounds(new LatLngBounds(region.farRight, region.nearLeft), RestrictBoundsFitMode.FIT_WIDTH);
|
||||
setMarker(latLng);
|
||||
}
|
||||
/**
|
||||
* 设置标注
|
||||
*/
|
||||
private void setMarker(LatLng latLng){
|
||||
|
||||
MarkerOptions options = new MarkerOptions().position(latLng);
|
||||
|
||||
//设置infowindow
|
||||
options.title("锚点");
|
||||
marker = tencentMap.addMarker(options);
|
||||
marker.setInfoWindowEnable(true);
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.tencent.map.vector.demo.camera;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.RestrictBoundsFitMode;
|
||||
|
||||
public class MapBoundActivity extends SupportMapFragmentActivity {
|
||||
private RadioGroup radioGroup;
|
||||
private CheckBox fitHeight;
|
||||
private CheckBox fitWidth;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
final LatLng northeastLatLng = new LatLng(39.984066, 116.307548);
|
||||
final LatLng southwestLatLng = new LatLng(39.974066, 116.297548);
|
||||
radioGroup = findViewById(R.id.lay_map_bound);
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
fitWidth = findViewById(R.id.btn_fit_width);
|
||||
fitWidth.setText("适应宽度");
|
||||
fitHeight = findViewById(R.id.btn_fit_height);
|
||||
fitHeight.setText("适应高度");
|
||||
fitHeight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_HEIGHT);
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fitWidth.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
tencentMap.setRestrictBounds(new LatLngBounds(northeastLatLng, southwestLatLng), RestrictBoundsFitMode.FIT_WIDTH);
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.tencent.map.vector.demo.camera;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class MapCameraCenterActivity extends SupportMapFragmentActivity implements TencentMap.OnCameraChangeListener, TencentMap.OnMapClickListener {
|
||||
private TextView textView;
|
||||
private String info;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
textView = findViewById(R.id.tv_info);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
tencentMap.setOnCameraChangeListener(this);
|
||||
tencentMap.setOnMapClickListener(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地图视图改变回调
|
||||
* @param cameraPosition
|
||||
*/
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
//获取当前地图视图信息
|
||||
info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom;
|
||||
textView.setText(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinished(CameraPosition cameraPosition) {
|
||||
//获取当前地图视图信息
|
||||
info = "经纬度:"+cameraPosition.target.latitude+","+cameraPosition.target.longitude+";zoom:"+cameraPosition.zoom;
|
||||
Toast.makeText(MapCameraCenterActivity.this,info,Toast.LENGTH_SHORT).show();
|
||||
textView.setText(info);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng,15f, 0, 0)));
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package com.tencent.map.vector.demo.circle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Arc;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.ArcOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerCollisionItem;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
|
||||
public class ArcActivity extends AppCompatActivity {
|
||||
|
||||
private MapView mapView;
|
||||
private TencentMap tencentMap;
|
||||
private boolean mMarkerAdded;
|
||||
private Arc arc;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_arc);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mapView = findViewById(R.id.mapView);
|
||||
tencentMap = mapView.getMap();
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(32.059352, 118.796623),
|
||||
5,
|
||||
0f,
|
||||
0f));
|
||||
//移动地图
|
||||
tencentMap.moveCamera(cameraSigma);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.markercol, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_collisionsmap).setVisible(!mMarkerAdded);
|
||||
menu.findItem(R.id.menu_close_collisionsmap).setVisible(mMarkerAdded);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_collisionsmap:
|
||||
mMarkerAdded = true;
|
||||
LatLng startLat = new LatLng(39.89491, 116.322056);
|
||||
LatLng endtLat = new LatLng(22.547, 114.085947);
|
||||
LatLng passLat = new LatLng(32.059352, 118.796623);
|
||||
ArcOptions arcOptions = new ArcOptions();
|
||||
arcOptions.points(startLat, endtLat);
|
||||
arcOptions.pass(passLat);
|
||||
//设置起点到终点,与起点外切线逆时针旋转的夹角角度
|
||||
arcOptions.angle(30);
|
||||
//设置线宽,默认5
|
||||
arcOptions.width(2);
|
||||
//设置线颜色,默认黑色
|
||||
arcOptions.color(Color.BLUE);
|
||||
arc = tencentMap.addArc(arcOptions);
|
||||
break;
|
||||
case R.id.menu_close_collisionsmap:
|
||||
mMarkerAdded = false;
|
||||
arc.remove();
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.tencent.map.vector.demo.circle;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Circle;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class CircleOptionsActivity extends SupportMapFragmentActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Circle circle = tencentMap.addCircle(circleOptions);
|
||||
Circle newCircle = tencentMap.addCircle(newCircleOptions);
|
||||
newCircle.setCenter(new LatLng(39.98408, 116.30701)); //重新设置圆心
|
||||
newCircle.setOptions(newCircleOptions); //重新设置圆形属性
|
||||
}
|
||||
|
||||
/**
|
||||
* 圆形选项
|
||||
*/
|
||||
private CircleOptions circleOptions = new CircleOptions() //圆形选项
|
||||
.center(new LatLng(39.9849, 116.3977)) //圆心位置
|
||||
.clickable(true) //支持点击
|
||||
.fillColor((128 << 24) + (100 << 16) + (50 << 8) + 120) //设置填充颜色RGBA
|
||||
.radius(110d) //设置半径
|
||||
.visible(true) //设置是否可见
|
||||
.zIndex(1) //设置堆叠顺序,越大优先级越高
|
||||
.strokeWidth(1) //描边宽度
|
||||
.strokeColor((128 << 24) + (128 << 16) + (128 << 8) + 128); //描边颜色
|
||||
|
||||
|
||||
private CircleOptions newCircleOptions = new CircleOptions().center(new LatLng(39.121, 116.454)).radius(90d).fillColor(0xff00ff00);
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.tencent.map.vector.demo.circle;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Circle;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class DrawCircleActivity extends SupportMapFragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LatLng latLng = new LatLng(39.984059,116.307771);
|
||||
Circle circle = tencentMap.addCircle(new CircleOptions().
|
||||
center(latLng).
|
||||
radius(100d).
|
||||
fillColor(getResources().getColor(R.color.style)).
|
||||
strokeColor(getResources().getColor(R.color.colorPrimary)).
|
||||
strokeWidth(1));
|
||||
}
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
package com.tencent.map.vector.demo.gesture;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
|
||||
public class GestureSettingsActivity extends SupportMapFragmentActivity {
|
||||
|
||||
private CheckBox scrollBox;
|
||||
private CheckBox zoomBox;
|
||||
private CheckBox rotateBox;
|
||||
private CheckBox tiltBox;
|
||||
private RadioGroup radioGroup;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
radioGroup = findViewById(R.id.lay_checkbox);
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
scrollBox = findViewById(R.id.btn_scroll);
|
||||
zoomBox = findViewById(R.id.btn_zoom);
|
||||
rotateBox = findViewById(R.id.btn_rotate);
|
||||
tiltBox = findViewById(R.id.btn_slope);
|
||||
|
||||
|
||||
scrollBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
mapUiSettings.setScrollGesturesEnabled(true);
|
||||
}else{
|
||||
mapUiSettings.setScrollGesturesEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
zoomBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
mapUiSettings.setZoomGesturesEnabled(true);
|
||||
}else{
|
||||
mapUiSettings.setZoomGesturesEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
rotateBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
mapUiSettings.setRotateGesturesEnabled(true);
|
||||
}else{
|
||||
mapUiSettings.setRotateGesturesEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tiltBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
if (b){
|
||||
mapUiSettings.setTiltGesturesEnabled(true);
|
||||
}else{
|
||||
mapUiSettings.setTiltGesturesEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package com.tencent.map.vector.demo.gesture;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||
|
||||
public class MapGestureListenActivity extends SupportMapFragmentActivity implements TencentMapGestureListener {
|
||||
|
||||
private TextView textView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
textView = findViewById(R.id.tv_info);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
tencentMap.setTencentMapGestureListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTap(float v, float v1) {
|
||||
textView.setText("单指双击");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSingleTap(float v, float v1) {
|
||||
textView.setText("单指单击");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFling(float v, float v1) {
|
||||
textView.setText("单指惯性滑动");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScroll(float v, float v1) {
|
||||
textView.setText("单指滑动");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongPress(float v, float v1) {
|
||||
textView.setText("长按");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDown(float v, float v1) {
|
||||
textView.setText("单指按下");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUp(float v, float v1) {
|
||||
textView.setText("单指抬起");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTwoFingerMoveAgainst(TwoFingerMoveAgainstStatus twoFingerMoveAgainstStatus, CameraPosition cameraPosition) {
|
||||
textView.setText("双指捏合");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStable() {
|
||||
textView.setText("地图稳定");
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapStableBy(CameraPosition.Trigger trigger) {
|
||||
textView.setText("地图稳定 by " + trigger.name());
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.tencent.map.vector.demo.gesture;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
public class MapListenActivity extends SupportMapFragmentActivity implements TencentMap.OnMapClickListener {
|
||||
private TextView textView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
textView = findViewById(R.id.tv_info);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
tencentMap.setOnMapClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
String info = "经纬度:" + latLng.latitude + "," + latLng.longitude;
|
||||
Toast.makeText(MapListenActivity.this, info, Toast.LENGTH_SHORT).show();
|
||||
textView.setText(info);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package com.tencent.map.vector.demo.gesture;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
|
||||
public class MapLongClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapLongClickListener {
|
||||
private TextView textView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
textView = findViewById(R.id.tv_info);
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
tencentMap.setOnMapLongClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLongClick(LatLng latLng) {
|
||||
String info = "经纬度:"+latLng.latitude+","+latLng.longitude;
|
||||
textView.setText(info);
|
||||
setMarker(latLng);
|
||||
}
|
||||
|
||||
/**
|
||||
* 长按添加标注
|
||||
*/
|
||||
private void setMarker(LatLng latLng){
|
||||
|
||||
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker));
|
||||
MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor);
|
||||
tencentMap.clear();
|
||||
tencentMap.addMarker(options);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Bitmap getBitMap(int resourceId){
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int newWidth = 100;
|
||||
int newHeight = 100;
|
||||
float widthScale = ((float)newWidth)/width;
|
||||
float heightScale = ((float)newHeight)/height;
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(widthScale, heightScale);
|
||||
bitmap = Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,197 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlay;
|
||||
import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlayProvider;
|
||||
import com.tencent.map.sdk.utilities.visualization.aggregation.HoneyCombVectorOverlayProvider;
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AggregationOverlayActivity extends AppCompatActivity {
|
||||
private MapView mMapView;
|
||||
private TencentMap mTencentMap;
|
||||
private AggregationOverlay aggregationOverlay;
|
||||
private AggregationOverlayProvider aggregationOverlayProvider;
|
||||
private Switch btnSwitch3D;
|
||||
|
||||
boolean mIsSelected;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_aggregation_overlay_design);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.vectorheatmap, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
|
||||
menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_vectorheatmap:
|
||||
addAggregation();
|
||||
break;
|
||||
case R.id.menu_close_vectorheatmap:
|
||||
mIsSelected = false;
|
||||
if (aggregationOverlay != null) {
|
||||
aggregationOverlay.remove();
|
||||
aggregationOverlay = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMapView = findViewById(R.id.mapView);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.setMapStyle(3);
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(10f));
|
||||
btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D);
|
||||
bindListener();
|
||||
}
|
||||
|
||||
|
||||
private void bindListener() {
|
||||
|
||||
CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
switch (compoundButton.getId()) {
|
||||
case R.id.btn_switch_3D:
|
||||
if (aggregationOverlay != null) {
|
||||
if (compoundButton.isChecked()) {
|
||||
aggregationOverlayProvider.enable3D(true);
|
||||
aggregationOverlayProvider.enable3D(true).setAnimateDuration(3000);
|
||||
} else {
|
||||
aggregationOverlayProvider.enable3D(false);
|
||||
}
|
||||
mTencentMap.updateVectorOverlay(aggregationOverlay, aggregationOverlayProvider);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener);
|
||||
|
||||
}
|
||||
|
||||
protected void addAggregation() {
|
||||
mIsSelected = true;
|
||||
if (aggregationOverlay != null) {
|
||||
return;
|
||||
}
|
||||
// mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.961629, 116.355343), 12, 0, 0)));
|
||||
mTencentMap.setBuildingEnable(false);
|
||||
mTencentMap.setPoisEnabled(false);
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
ArrayList<WeightedLatLng> nodes = new ArrayList<WeightedLatLng>();
|
||||
br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k")));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] lines = line.split("\t");
|
||||
if (lines.length == 3) {
|
||||
double value = Double.parseDouble(lines[2]);
|
||||
LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0])));
|
||||
nodes.add(new WeightedLatLng(latLng, value));
|
||||
}
|
||||
}
|
||||
|
||||
int[] colors = {
|
||||
Color.argb(255, 0x01, 0x2C, 0x4B),
|
||||
Color.argb(255, 0x17, 0x3E, 0x59),
|
||||
Color.argb(255, 0x3A, 0x73, 0x78),
|
||||
Color.argb(255, 0x98, 0xCD, 0x9A),
|
||||
Color.argb(255, 0xF6, 0xFB, 0xB6)
|
||||
};
|
||||
double[] startPoints = {0.f, 0.1f, 0.15f, 0.3f, 0.5f};
|
||||
|
||||
|
||||
aggregationOverlayProvider = new HoneyCombVectorOverlayProvider()
|
||||
.nodes(nodes.toArray(new WeightedLatLng[0]))
|
||||
.setHeightRange(0, 4000);
|
||||
aggregationOverlayProvider.colors(colors, startPoints);
|
||||
aggregationOverlay = mTencentMap.addVectorOverlay(aggregationOverlayProvider);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.FromToLatLng;
|
||||
import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlay;
|
||||
import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlayProvider;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ArcLineLayerActivity extends AppCompatActivity {
|
||||
private MapView mMapView;
|
||||
private TencentMap mTencentMap;
|
||||
private VectorOverlay vectorOverlay;
|
||||
private ArcLineOverlayProvider options;
|
||||
private Switch btnSwitch3D;
|
||||
boolean mIsSelected;
|
||||
private Switch btnani3D;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_arc_line_layer_design);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.vectorheatmap, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
|
||||
menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_vectorheatmap:
|
||||
btnSwitch3D.setVisibility(View.VISIBLE);
|
||||
addArcLineLayer();
|
||||
break;
|
||||
case R.id.menu_close_vectorheatmap:
|
||||
mIsSelected = false;
|
||||
if (vectorOverlay != null) {
|
||||
vectorOverlay.remove();
|
||||
vectorOverlay = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMapView = findViewById(R.id.mapView);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f));
|
||||
btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D);
|
||||
bindListener();
|
||||
|
||||
}
|
||||
|
||||
private void bindListener() {
|
||||
CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
|
||||
switch (compoundButton.getId()) {
|
||||
case R.id.btn_switch_3D:
|
||||
if (vectorOverlay != null) {
|
||||
if (compoundButton.isChecked()) {
|
||||
options.enable3D(true);
|
||||
} else {
|
||||
options.enable3D(false);
|
||||
}
|
||||
|
||||
mTencentMap.updateVectorOverlay(vectorOverlay, options);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener);
|
||||
}
|
||||
|
||||
private void addArcLineLayer() {
|
||||
mIsSelected = true;
|
||||
if (vectorOverlay == null) {
|
||||
// mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.9229731, 116.422880668), 8, 0f, 0f)));
|
||||
mTencentMap.setMapStyle(3);
|
||||
|
||||
int color = Color.argb(255, 0, 255, 170);
|
||||
BufferedReader br = null;
|
||||
final ArrayList<FromToLatLng> nodes = new ArrayList<FromToLatLng>();
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("arc.dat")));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] lines = line.split(" ");
|
||||
if (lines.length == 5) {
|
||||
double arc = Double.parseDouble(lines[4]);
|
||||
LatLng startLatLng = new LatLng((Double.parseDouble(lines[0])), (Double.parseDouble(lines[1])));
|
||||
LatLng endLatLng = new LatLng((Double.parseDouble(lines[2])), (Double.parseDouble(lines[3])));
|
||||
nodes.add(new FromToLatLng(startLatLng, endLatLng));
|
||||
//nodes.add(new FromToLatLng(startLatLng, endLatLng, arc));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int[] colors = {
|
||||
Color.argb(255, 0, 0xd4, 0xff),
|
||||
Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff),
|
||||
Color.argb(255, 0, 0xd4, 0xff)
|
||||
};
|
||||
options = new ArcLineOverlayProvider().data(nodes).opacity(2f).width(4).gradient(colors).setAnimateDuration(3000).setHighlightDuration(200).animateColor(Color.argb(255, 0xff, 0xff, 0xff));
|
||||
vectorOverlay = mTencentMap.addVectorOverlay(options);
|
||||
mTencentMap.setPoisEnabled(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.map.sdk.utilities.heatmap.Gradient;
|
||||
import com.tencent.map.sdk.utilities.heatmap.HeatMapTileProvider;
|
||||
import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DrawHeatOverlayActivity extends SupportMapFragmentActivity implements HeatMapTileProvider.OnHeatMapReadyListener{
|
||||
|
||||
private TileOverlay mHeatmapTileOverlay;
|
||||
private HeatMapTileProvider mProvider;
|
||||
//热力图半径
|
||||
private static final int ALT_HEATMAP_RADIUS = HeatMapTileProvider.DEFAULT_RADIUS;
|
||||
//热力图透明度
|
||||
private static final double ALT_HEATMAP_OPACITY = HeatMapTileProvider.DEFAULT_OPACITY;
|
||||
//热力图渐变方案
|
||||
public static final Gradient ALT_HEATMAP_GRADIENT = HeatMapTileProvider.DEFAULT_GRADIENT;
|
||||
|
||||
private static final int[] CUSTOM_GRADIENT_COLORS = {
|
||||
Color.argb(0,0, 225, 225),
|
||||
Color.rgb(102, 125, 200),
|
||||
Color.rgb(255, 0, 0)
|
||||
};
|
||||
|
||||
private static final float[] CUSTOM_GRADIENT_START_POINTS = {
|
||||
0.0f, 0.2f, 1f
|
||||
};
|
||||
|
||||
public static final Gradient CUSTOM_HEATMAP_GRADIENT = new Gradient(CUSTOM_GRADIENT_COLORS,
|
||||
CUSTOM_GRADIENT_START_POINTS);
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setUpMap();
|
||||
Button first = findViewById(R.id.btn_bottom);
|
||||
first.setVisibility(View.VISIBLE);
|
||||
first.setText("自定义热力图");
|
||||
first.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mProvider.setHeatTileGenerator(new HeatMapTileProvider.HeatTileGenerator() {
|
||||
@Override
|
||||
public double[] generateKernel(int radius) {
|
||||
double[] kernel = new double[radius * 2 + 1];
|
||||
for (int i = -radius; i <= radius; i++) {
|
||||
kernel[i + radius] = Math.exp(-i * i / (2 * (radius / 2f) * (radius / 2f)));
|
||||
}
|
||||
return kernel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] generateColorMap(double opacity) {
|
||||
return CUSTOM_HEATMAP_GRADIENT.generateColorMap(opacity);
|
||||
}
|
||||
});
|
||||
mHeatmapTileOverlay.clearTileCache();
|
||||
mHeatmapTileOverlay.reload();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
private void setUpMap() {
|
||||
tencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new com.tencent.tencentmap.mapsdk.maps.model.LatLng(39.917128, 116.399266),
|
||||
7.946870f));
|
||||
initHeatMap();
|
||||
}
|
||||
private void initHeatMap() {
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
ArrayList<WeightedLatLng> nodes = new ArrayList<>();
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
getResources().getAssets().open("data2k")));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] lines = line.split("\t");
|
||||
if (lines.length == 3) {
|
||||
double value = Double.parseDouble(lines[2]);
|
||||
LatLng latLng = new LatLng((Double.parseDouble(lines[1])),
|
||||
(Double.parseDouble(lines[0])));
|
||||
nodes.add(new WeightedLatLng(latLng, value));
|
||||
}
|
||||
}
|
||||
|
||||
mProvider = new HeatMapTileProvider.Builder()
|
||||
.weightedData(nodes)
|
||||
.gradient(ALT_HEATMAP_GRADIENT)
|
||||
.opacity(ALT_HEATMAP_OPACITY)
|
||||
.radius(ALT_HEATMAP_RADIUS)
|
||||
.readyListener(this)
|
||||
.build(tencentMap);
|
||||
mHeatmapTileOverlay = tencentMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeatMapReady() {
|
||||
mHeatmapTileOverlay.clearTileCache();
|
||||
mHeatmapTileOverlay.reload();
|
||||
}
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
|
||||
public class DrawOldVersionHeatOverlayActivity extends SupportMapFragmentActivity {
|
||||
|
||||
|
||||
// private HeatOverlay heatOverlay;
|
||||
// private HeatOverlay newHeatOverlay;
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// HeatOverlayOptions options = setHeatMap(getHeatDataNodes()); //热力图选项
|
||||
// HeatOverlayOptions newOptions = setHeatMap(transferHeatNodes(getHeatDataNodes())); //新的热力图选项
|
||||
//
|
||||
//
|
||||
// heatOverlay = tencentMap.addHeatOverlay(options); //绘制热力图
|
||||
// heatOverlay.remove(); //移除热力图
|
||||
//
|
||||
// newHeatOverlay = tencentMap.addHeatOverlay(newOptions); //绘制转换过坐标的热力图
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 设置热力图Options
|
||||
// *
|
||||
// */
|
||||
// private HeatOverlayOptions setHeatMap(ArrayList<HeatDataNode> nodes){
|
||||
// //配置热力图参数
|
||||
// HeatOverlayOptions heatOverlayOptions = new HeatOverlayOptions();
|
||||
// heatOverlayOptions.nodes(nodes)
|
||||
// .radius(18)// 半径,单位是像素,这个数值越大运算量越大,默认值为18,建议设置在18-30之间)
|
||||
// .colorMapper(new ColorMapper())
|
||||
// .onHeatMapReadyListener(()->{
|
||||
// runOnUiThread(()-> {
|
||||
// Toast.makeText(getApplicationContext(),
|
||||
// "热力图数据准备完毕", Toast.LENGTH_SHORT).show();
|
||||
// });
|
||||
// });
|
||||
// return heatOverlayOptions;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 配色方案
|
||||
// */
|
||||
// class ColorMapper implements HeatOverlayOptions.IColorMapper {
|
||||
//
|
||||
// @Override
|
||||
// public int colorForValue(double arg0) {
|
||||
// // TODO Auto-generated method stub
|
||||
// int alpha, red, green, blue;
|
||||
// if (arg0 > 1) {
|
||||
// arg0 = 1;
|
||||
// }
|
||||
// arg0 = Math.sqrt(arg0);
|
||||
// float a = 20000;
|
||||
// red = 255;
|
||||
// green = 119;
|
||||
// blue = 3;
|
||||
// if (arg0 > 0.7) {
|
||||
// green = 78;
|
||||
// blue = 1;
|
||||
// }
|
||||
// if (arg0 > 0.6) {
|
||||
// alpha = (int) (a * Math.pow(arg0 - 0.7, 3) + 240);
|
||||
// } else if (arg0 > 0.4) {
|
||||
// alpha = (int) (a * Math.pow(arg0 - 0.5, 3) + 200);
|
||||
// } else if (arg0 > 0.2) {
|
||||
// alpha = (int) (a * Math.pow(arg0 - 0.3, 3) + 160);
|
||||
// } else {
|
||||
// alpha = (int) (700 * arg0);
|
||||
// }
|
||||
// if (alpha > 255) {
|
||||
// alpha = 255;
|
||||
// }
|
||||
// return Color.argb(alpha, red, green, blue);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 准备热力图数据
|
||||
// * @return
|
||||
// */
|
||||
// private ArrayList<HeatDataNode> getHeatDataNodes(){
|
||||
// //HeatDataNode 是热力图热点,包括热点位置和热度值(HeatOverlay会根据传入的全部节点的热度值范围计算最终的颜色表现)
|
||||
// ArrayList<HeatDataNode> nodes = new ArrayList<>();
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984108,116.307557), 86));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984208,116.307457), 44));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.983208,116.307457), 64));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.983208,116.317457), 54));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.684308,116.317457), 34));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.684108,116.307457), 24));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984408,116.327457), 44));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984508,116.307457), 54));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984208,116.307457), 14));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984298,116.307457), 64));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984208,116.327457), 74));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.984108,116.317457), 84));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.983208,116.297457), 65));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.982208,116.307457), 54));
|
||||
// nodes.add(new HeatDataNode(new LatLng(39.985208,116.297457), 69));
|
||||
// return nodes;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private ArrayList<HeatDataNode> transferHeatNodes(ArrayList<HeatDataNode> nodes){
|
||||
// ArrayList<HeatDataNode> newNodes = new ArrayList<HeatDataNode>();
|
||||
// for (HeatDataNode node: nodes){
|
||||
// newNodes.add(new HeatDataNode(new LatLng(node.getPoint().getLatitude() + 0.01, node.getPoint().getLongitude() - 0.01), Math.floor(node.getValue() + Math.random())));
|
||||
//
|
||||
// }
|
||||
// return newNodes;
|
||||
// }
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlay;
|
||||
import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.GeneralTranslateAnimator;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.IAnimatorModel;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.GeoGraphicType;
|
||||
import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.PixelType;
|
||||
|
||||
public class GLModelActivity extends AppCompatActivity {
|
||||
|
||||
/**
|
||||
* 和其他覆盖物相同三维模型图也可控制图层的Level和zIndex
|
||||
* 可通过 GLModelOverlayProvider的displayLevel和zIndex进行设置
|
||||
* displayLevel - 默认层级为POI之下 OverlayLevel.OverlayLevelAboveBuildings
|
||||
* 相同Level内的显示层级关系通过zIndex(int)来控制,zIndex越大越靠上显示。 Level优先级高于zIndex displayLevel必须为如下值之一,否则不生效
|
||||
*/
|
||||
|
||||
private MapView mapView;
|
||||
protected TencentMap tencentMap;
|
||||
private String mResourcePath;
|
||||
private GLModelOverlay vectorOverlay;
|
||||
private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697";
|
||||
private LatLng[] mCarLatLngArray;
|
||||
private GeneralTranslateAnimator animator;
|
||||
private Polyline polyline;
|
||||
private Spinner mSpinner;
|
||||
private String[] glmodelAnimator = new String[]{"开启平滑移动", "开启骨骼动画", "关闭骨骼动画"};
|
||||
private GLModelOverlayProvider provider;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_g_l_model);
|
||||
mapView = findViewById(R.id.mapView);
|
||||
tencentMap = this.mapView.getMap();
|
||||
String[] linePointsStr = mLine.split(",");
|
||||
mCarLatLngArray = new LatLng[linePointsStr.length / 4];
|
||||
|
||||
for (int i = 0; i < mCarLatLngArray.length; i++) {
|
||||
double latitude = Double.parseDouble(linePointsStr[i * 4]);
|
||||
double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]);
|
||||
mCarLatLngArray[i] = new LatLng(latitude, longitude);
|
||||
}
|
||||
polyline = tencentMap.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorAccent).arrow(true));
|
||||
tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50));
|
||||
creatglmode();
|
||||
init();
|
||||
}
|
||||
|
||||
private void creatglmode() {
|
||||
//gltf格式三维模型文件在assets内
|
||||
String file = "BrainStem.gltf";
|
||||
String SKELETON_PATH = "gltf-BrainStem";
|
||||
//获取外部存储
|
||||
mResourcePath = getExternalFilesDir(null).getAbsolutePath() + File.separator + SKELETON_PATH;
|
||||
provider = new GLModelOverlayProvider(
|
||||
mResourcePath + File.separator + file,
|
||||
new LatLng(39.98409, 116.30804)).coordType(PixelType)
|
||||
.pixelBounds(400, 1200).rotationX(90).rotationY(0).rotationZ(0).setClickEnable(true);
|
||||
vectorOverlay = tencentMap.addVectorOverlay(provider);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mSpinner = findViewById(R.id.sp_glmode);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, glmodelAnimator);
|
||||
mSpinner.setAdapter(adapter);
|
||||
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
//开启骨骼动画
|
||||
case 0:
|
||||
animator = new GeneralTranslateAnimator.Builder(vectorOverlay, 6000,
|
||||
mCarLatLngArray).rotateEnabled(true).initRotate(180).modelType(GeneralTranslateAnimator.ModelType.MODEL_OVERLAY).build();
|
||||
animator.startAnimation();
|
||||
animator.addAnimatorEndListener(new IAnimatorModel.IAnimatorEndListener() {
|
||||
@Override
|
||||
public void onAnimatorEnd() {
|
||||
Log.i("TransformActivity", "onAnimatorEnd");
|
||||
}
|
||||
});
|
||||
break;
|
||||
//停止骨骼动画
|
||||
case 1:
|
||||
vectorOverlay.playSkeletonAnimation(0, 1, true);
|
||||
break;
|
||||
//模型平移
|
||||
case 2:
|
||||
vectorOverlay.stopSkeletonAnimation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* mapview的生命周期管理
|
||||
*/
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
vectorOverlay.remove();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
mapView.onRestart();
|
||||
}
|
||||
}
|
@ -1,171 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng;
|
||||
import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlay;
|
||||
import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlayProvider;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HeatMapVectorOverlayActivity extends AppCompatActivity {
|
||||
private MapView mMapView;
|
||||
private TencentMap mTencentMap;
|
||||
private GradientVectorOverlay heatTileOverlay;
|
||||
private GradientVectorOverlayProvider heatMapTileProvider;
|
||||
boolean mIsSelected;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_heat_map_vector_overlay_design);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.vectorheatmap, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
|
||||
menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_vectorheatmap:
|
||||
addHeatMap();
|
||||
break;
|
||||
case R.id.menu_close_vectorheatmap:
|
||||
mIsSelected = false;
|
||||
if (heatTileOverlay != null) {
|
||||
heatTileOverlay.remove();
|
||||
heatTileOverlay = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMapView = findViewById(R.id.mapView);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.setMapStyle(3);
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(31.085414, 111.024319),
|
||||
4,
|
||||
20f,
|
||||
1f));
|
||||
mTencentMap.moveCamera(cameraSigma);
|
||||
}
|
||||
|
||||
|
||||
private void addHeatMap() {
|
||||
mIsSelected = true;
|
||||
if (heatTileOverlay != null) {
|
||||
return;
|
||||
}
|
||||
mTencentMap.setBuildingEnable(false);
|
||||
mTencentMap.setPoisEnabled(false);
|
||||
BufferedReader br = null;
|
||||
try {
|
||||
ArrayList<WeightedLatLng> nodes = new ArrayList<WeightedLatLng>();
|
||||
br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k")));
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] lines = line.split("\t");
|
||||
if (lines.length == 3) {
|
||||
double value = Double.parseDouble(lines[2]);
|
||||
LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0])));
|
||||
nodes.add(new WeightedLatLng(latLng, value));
|
||||
}
|
||||
}
|
||||
|
||||
// 通用配色1
|
||||
int[] colors = {
|
||||
Color.argb(255, 77, 111, 255),
|
||||
Color.argb(255, 0, 238, 227),
|
||||
Color.argb(255, 113, 236, 80),
|
||||
Color.argb(255, 255, 176, 0),
|
||||
Color.argb(255, 255, 72, 0)
|
||||
};
|
||||
float[] startPoints = {0.1f, 0.185f, 0.3571f, 0.6142f, 1f};
|
||||
|
||||
|
||||
heatMapTileProvider = new GradientVectorOverlayProvider()
|
||||
.weightedData(nodes).enable3D(true)
|
||||
.radius(56).setMaxHeight(500).setAnimateDuration(3000);
|
||||
heatMapTileProvider.opacity(0.95f);
|
||||
heatMapTileProvider.gradient(colors, startPoints);
|
||||
heatTileOverlay = mTencentMap.addVectorOverlay(heatMapTileProvider);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.ScatterLatLng;
|
||||
import com.tencent.map.sdk.utilities.visualization.scatterplot.BitmapScatterPlotOverlayProvider;
|
||||
import com.tencent.map.sdk.utilities.visualization.scatterplot.DotScatterPlotOverlayProvider;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class ScatterPlotOverlayActivity extends AppCompatActivity {
|
||||
private MapView mMapView;
|
||||
private TencentMap mTencentMap;
|
||||
private VectorOverlay vectorOverlay;
|
||||
boolean mIsSelected;
|
||||
private DotScatterPlotOverlayProvider dotScatterPlotOverlayProvider;
|
||||
private BitmapScatterPlotOverlayProvider provider;
|
||||
private String[] styles = new String[]{"添加点散点", "添加图片散点"};
|
||||
private Spinner mSpinner;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_scatter_plot_overlay);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMapView = findViewById(R.id.mapView);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f));
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(40.040219, 116.273348), 20, 0, 0)));
|
||||
mSpinner = findViewById(R.id.sp_style);
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles);
|
||||
mSpinner.setAdapter(adapter);
|
||||
mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
if (vectorOverlay != null) {
|
||||
vectorOverlay.remove();
|
||||
vectorOverlay = null;
|
||||
}
|
||||
addDotVectorOverlay();
|
||||
mTencentMap.updateVectorOverlay(vectorOverlay, dotScatterPlotOverlayProvider);
|
||||
break;
|
||||
case 1:
|
||||
if (vectorOverlay != null) {
|
||||
vectorOverlay.remove();
|
||||
vectorOverlay = null;
|
||||
}
|
||||
addBitmapVectorOverlay();
|
||||
mTencentMap.updateVectorOverlay(vectorOverlay, provider);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void addDotVectorOverlay() {
|
||||
mIsSelected = true;
|
||||
if (vectorOverlay == null) {
|
||||
BufferedReader br = null;
|
||||
final ArrayList<ScatterLatLng> nodes = new ArrayList<ScatterLatLng>();
|
||||
double lat = 40.040219;
|
||||
double lng = 116.273348;
|
||||
double value = 100;
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < 2000; i++) {
|
||||
double a = r.nextInt(10) * 1E-5;
|
||||
double b = r.nextInt(10) * 1E-5;
|
||||
LatLng latLng = new LatLng(lat + a, lng + b);
|
||||
nodes.add(new ScatterLatLng(latLng, value));
|
||||
}
|
||||
int[] colors = {
|
||||
Color.argb(255, 0, 0xd4, 0xff),
|
||||
Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff),
|
||||
Color.argb(255, 0, 0xd4, 0xff)
|
||||
};
|
||||
|
||||
dotScatterPlotOverlayProvider = new DotScatterPlotOverlayProvider().data(nodes).opacity(2f).radius(2).animate(true).colors(colors);
|
||||
|
||||
vectorOverlay = mTencentMap.addVectorOverlay(dotScatterPlotOverlayProvider);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addBitmapVectorOverlay() {
|
||||
mIsSelected = true;
|
||||
if (vectorOverlay == null) {
|
||||
final ArrayList<ScatterLatLng> nodes = new ArrayList<ScatterLatLng>();
|
||||
double lat = 40.040219;
|
||||
double lng = 116.273348;
|
||||
double value = 10;
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
double a = r.nextInt(10) * 1E-5;
|
||||
double b = r.nextInt(10) * 1E-5;
|
||||
LatLng latLng = new LatLng(lat + a, lng + b);
|
||||
nodes.add(new ScatterLatLng(latLng, value));
|
||||
}
|
||||
BitmapDescriptor[] bitmaps = {
|
||||
BitmapDescriptorFactory.fromAsset("21.jpg"),
|
||||
BitmapDescriptorFactory.fromAsset("22.jpg"),
|
||||
BitmapDescriptorFactory.fromAsset("23.jpg"),
|
||||
BitmapDescriptorFactory.fromAsset("24.jpg"),
|
||||
BitmapDescriptorFactory.fromAsset("25.jpg"),
|
||||
BitmapDescriptorFactory.fromAsset("26.jpg"),
|
||||
};
|
||||
provider = new BitmapScatterPlotOverlayProvider().data(nodes).bitmaps(bitmaps).opacity(2f).scale(20, 10);
|
||||
vectorOverlay = mTencentMap.addVectorOverlay(provider);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.TimeLatLng;
|
||||
import com.tencent.map.sdk.utilities.visualization.datamodels.TrailLatLng;
|
||||
import com.tencent.map.sdk.utilities.visualization.trails.TrailOverlayProvider;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TrailOverlayActivity extends AppCompatActivity {
|
||||
private MapView mMapView;
|
||||
private TencentMap mTencentMap;
|
||||
private VectorOverlay vectorOverlay;
|
||||
boolean mIsSelected;
|
||||
private TrailOverlayProvider trailOverlayProvider;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_trail_overlay);
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.vectorheatmap, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
|
||||
menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_vectorheatmap:
|
||||
addArcLineLayer();
|
||||
break;
|
||||
case R.id.menu_close_vectorheatmap:
|
||||
mIsSelected = false;
|
||||
if (vectorOverlay != null) {
|
||||
vectorOverlay.remove();
|
||||
vectorOverlay = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mMapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mMapView = findViewById(R.id.mapView);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.942117, 116.33668), 11));
|
||||
}
|
||||
|
||||
private void addArcLineLayer() {
|
||||
mIsSelected = true;
|
||||
if (vectorOverlay == null) {
|
||||
|
||||
mTencentMap.setPoisEnabled(false);
|
||||
BufferedReader br = null;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
List<TrailLatLng> startLats = new ArrayList<>();
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("trailData.dat")));
|
||||
|
||||
String line = null;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] oneDot = line.split(",");
|
||||
TimeLatLng[] timeLatLngs = new TimeLatLng[oneDot.length];
|
||||
int i = 0;
|
||||
for (String timeLatLng : oneDot) {
|
||||
String[] values = timeLatLng.split("\t");
|
||||
LatLng latlng = new LatLng((Double.parseDouble(values[0])), (Double.parseDouble(values[1])));
|
||||
int timeStamp = Integer.parseInt(values[2]);
|
||||
timeLatLngs[i++] = new TimeLatLng(latlng, timeStamp);
|
||||
}
|
||||
TrailLatLng tmp = new TrailLatLng(timeLatLngs);
|
||||
startLats.add(tmp);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
int[] colors = {Color.argb(0xff, 0x00, 0x00, 0xff),
|
||||
Color.argb(0x00, 0xff, 0xff, 0x00)};
|
||||
|
||||
trailOverlayProvider = new TrailOverlayProvider().type(TrailOverlayProvider.TrailOverlayType.Trail).data(startLats).opacity(2f).width(10).gradient(colors).setHighlightDuration(8000).setAnimateStartTime(0, 25000);
|
||||
vectorOverlay = mTencentMap.addVectorOverlay(trailOverlayProvider);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,182 +0,0 @@
|
||||
package com.tencent.map.vector.demo.heatoverlay;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng;
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.MapView;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatAggregationUnit;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlay;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlayOptions;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 蜂窝热力图
|
||||
*/
|
||||
public class VectorHeatMapActivity extends SupportMapFragmentActivity {
|
||||
|
||||
MapView mMapView;
|
||||
TencentMap mTencentMap;
|
||||
VectorHeatOverlay mOverlay;
|
||||
boolean mIsSelected;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_vector_heat_map);
|
||||
mMapView = findViewById(R.id.map_view);
|
||||
mTencentMap = mMapView.getMap();
|
||||
mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(36.139985, 120.402243),
|
||||
11));
|
||||
|
||||
mTencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng latlng) {
|
||||
if (mOverlay == null) {
|
||||
return;
|
||||
}
|
||||
VectorHeatAggregationUnit unit = mOverlay.getUnit(latlng);
|
||||
if (unit == null) {
|
||||
Log.e("VectorHeatMapActivity", "no unit found");
|
||||
return;
|
||||
}
|
||||
Log.e("VectorHeatMapActivity", "unit center:" + unit.getCenter() +
|
||||
", intensity:" + unit.getIntensity() +
|
||||
", size:" + unit.getNodes().length);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.vectorheatmap, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
|
||||
menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_open_vectorheatmap:
|
||||
addVectorHeatMap();
|
||||
break;
|
||||
case R.id.menu_close_vectorheatmap:
|
||||
removeVectorHeatMap();
|
||||
break;
|
||||
}
|
||||
|
||||
supportInvalidateOptionsMenu();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private ArrayList<WeightedLatLng> getHeatNodes() {
|
||||
BufferedReader br = null;
|
||||
ArrayList<WeightedLatLng> nodes = null;
|
||||
try {
|
||||
nodes = new ArrayList<>();
|
||||
br = new BufferedReader(new InputStreamReader(
|
||||
getResources().getAssets().open("honeycomb.txt")));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] lines = line.split("\t");
|
||||
if (lines.length == 3) {
|
||||
double value = Double.parseDouble(lines[2]);
|
||||
LatLng latLng = new LatLng((Double.parseDouble(lines[1])),
|
||||
(Double.parseDouble(lines[0])));
|
||||
nodes.add(new WeightedLatLng(latLng, 1));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mMapView != null) {
|
||||
mMapView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (mMapView != null) {
|
||||
mMapView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (mMapView != null) {
|
||||
mMapView.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mMapView != null) {
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void addVectorHeatMap() {
|
||||
mIsSelected = true;
|
||||
if (mOverlay != null) {
|
||||
return;
|
||||
}
|
||||
WeightedLatLng[] nodes = getHeatNodes().toArray(new WeightedLatLng[0]);
|
||||
VectorHeatOverlayOptions options = new VectorHeatOverlayOptions()
|
||||
.nodes(nodes)
|
||||
.size(2000)
|
||||
.gap(100)
|
||||
.colors(new int[]{0x45fa4b14, 0x99fa4b14, 0xd9fa4b14})
|
||||
.startPoints(new double[]{0, 0.6, 0.8});
|
||||
mOverlay = mTencentMap.addVectorHeatOverlay(options);
|
||||
}
|
||||
|
||||
public void removeVectorHeatMap() {
|
||||
mIsSelected = false;
|
||||
if (mOverlay == null) {
|
||||
return;
|
||||
}
|
||||
mOverlay.remove();
|
||||
mOverlay = null;
|
||||
}
|
||||
}
|
@ -1,251 +0,0 @@
|
||||
package com.tencent.map.vector.demo.location;
|
||||
|
||||
import android.Manifest;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.location.Location;
|
||||
import android.os.Looper;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import cc.winboll.studio.positions.R;
|
||||
import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity;
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentLocationListener;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
import com.tencent.map.geolocation.TencentLocationRequest;
|
||||
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import pub.devrel.easypermissions.EasyPermissions;
|
||||
|
||||
public class LocationLayerActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks, LocationSource, TencentLocationListener, TencentMap.OnMapLongClickListener, RadioGroup.OnCheckedChangeListener {
|
||||
|
||||
private OnLocationChangedListener locationChangedListener;
|
||||
|
||||
private TencentLocationManager locationManager;
|
||||
private TencentLocationRequest locationRequest;
|
||||
private MyLocationStyle locationStyle;
|
||||
private RadioGroup radioGroup;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
//定位需要申请的权限
|
||||
String[] perms = {
|
||||
Manifest.permission.ACCESS_FINE_LOCATION,
|
||||
Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||
Manifest.permission.READ_PHONE_STATE
|
||||
};
|
||||
|
||||
if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限
|
||||
Log.i("location", "已获取权限");
|
||||
} else {
|
||||
EasyPermissions.requestPermissions(this, "必要的权限", 0, perms);
|
||||
}
|
||||
//设置显示定位的图标
|
||||
mapUiSettings.setMyLocationButtonEnabled(true);
|
||||
tencentMap.setOnMapLongClickListener(this);
|
||||
|
||||
radioGroup = findViewById(R.id.location_type);
|
||||
radioGroup.setVisibility(View.VISIBLE);
|
||||
radioGroup.setOnCheckedChangeListener(this);
|
||||
|
||||
//建立定位
|
||||
initLocation();
|
||||
//SDK版本4.3.5新增内置定位标点击回调监听
|
||||
tencentMap.setMyLocationClickListener(new TencentMap.OnMyLocationClickListener() {
|
||||
@Override
|
||||
public boolean onMyLocationClicked(LatLng latLng) {
|
||||
Toast.makeText(LocationLayerActivity.this, "内置定位标点击回调", Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 定位的一些初始化设置
|
||||
*/
|
||||
private void initLocation() {
|
||||
//用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
|
||||
locationManager = TencentLocationManager.getInstance(this);
|
||||
//设置坐标系
|
||||
locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
|
||||
//创建定位请求
|
||||
locationRequest = TencentLocationRequest.create();
|
||||
//设置定位周期(位置监听器回调周期)为3s
|
||||
locationRequest.setInterval(3000);
|
||||
|
||||
//地图上设置定位数据源
|
||||
tencentMap.setLocationSource(this);
|
||||
//设置当前位置可见
|
||||
tencentMap.setMyLocationEnabled(true);
|
||||
//设置定位图标样式
|
||||
setLocMarkerStyle();
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定位图标样式
|
||||
*/
|
||||
private void setLocMarkerStyle() {
|
||||
locationStyle = new MyLocationStyle();
|
||||
//创建图标
|
||||
BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location_icon));
|
||||
locationStyle.icon(bitmapDescriptor);
|
||||
//设置定位圆形区域的边框宽度
|
||||
locationStyle.strokeWidth(3);
|
||||
//设置圆区域的颜色
|
||||
locationStyle.fillColor(R.color.style);
|
||||
}
|
||||
|
||||
private Bitmap getBitMap(int resourceId) {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
|
||||
int width = bitmap.getWidth();
|
||||
int height = bitmap.getHeight();
|
||||
int newWidth = 55;
|
||||
int newHeight = 55;
|
||||
float widthScale = ((float) newWidth) / width;
|
||||
float heightScale = ((float) newHeight) / height;
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.postScale(widthScale, heightScale);
|
||||
bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现位置监听
|
||||
*
|
||||
* @param tencentLocation
|
||||
* @param i
|
||||
* @param s
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
||||
|
||||
if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
|
||||
Location location = new Location(tencentLocation.getProvider());
|
||||
//设置经纬度以及精度
|
||||
location.setLatitude(tencentLocation.getLatitude());
|
||||
location.setLongitude(tencentLocation.getLongitude());
|
||||
location.setAccuracy(tencentLocation.getAccuracy());
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
|
||||
//显示回调的实时位置信息
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//打印tencentLocation的json字符串
|
||||
// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusUpdate(String s, int i, String s1) {
|
||||
//GPS, WiFi, Radio 等状态发生变化
|
||||
Log.v("State changed", s + "===" + s1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void activate(OnLocationChangedListener onLocationChangedListener) {
|
||||
locationChangedListener = onLocationChangedListener;
|
||||
|
||||
int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper());
|
||||
switch (err) {
|
||||
case 1:
|
||||
Toast.makeText(this, "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 2:
|
||||
Toast.makeText(this, "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case 3:
|
||||
Toast.makeText(this, "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
locationRequest = null;
|
||||
locationChangedListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "success");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||
Log.e("location quest: ", "failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLongClick(LatLng latLng) {
|
||||
Location location = new Location("LongPressLocationProvider");
|
||||
location.setLatitude(latLng.latitude);
|
||||
location.setLongitude(latLng.longitude);
|
||||
location.setAccuracy(20);
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
Log.i("long click", new Gson().toJson(latLng));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
||||
switch (i) {
|
||||
//连续定位,但不会移动到地图中心点,并且会跟随设备移动
|
||||
case R.id.btn_follow_no_center:
|
||||
|
||||
initLocation();
|
||||
locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
break;
|
||||
//连续定位,且将视角移动到地图中心,定位点依照设备方向旋转,并且会跟随设备移动,默认是此种类型
|
||||
case R.id.btn_location_rotate:
|
||||
|
||||
initLocation();
|
||||
locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
break;
|
||||
//连续定位,但不会移动到地图中心点,定位点依照设备方向旋转,并且跟随设备移动
|
||||
case R.id.btn_location_rotate_no_center:
|
||||
|
||||
initLocation();
|
||||
locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
break;
|
||||
//连续定位,但不会移动到地图中心点,地图依照设备方向旋转,并且会跟随设备移动
|
||||
case R.id.btn_map_rotate_no_center:
|
||||
|
||||
initLocation();
|
||||
locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER);
|
||||
tencentMap.setMyLocationStyle(locationStyle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|