diff --git a/positions/build.gradle b/positions/build.gradle index 6b37ca8..b6d9cf9 100644 --- a/positions/build.gradle +++ b/positions/build.gradle @@ -66,37 +66,36 @@ dependencies { implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.5.4.3' implementation 'com.google.code.gson:gson:2.8.5' // 权限申请框架 - implementation 'pub.devrel:easypermissions:2.0.1' + //implementation 'pub.devrel:easypermissions:2.0.1' // 权限申请框架:https://github.com/getActivity/XXPermissions - implementation 'com.github.getActivity:XXPermissions:18.63' + //implementation 'com.github.getActivity:XXPermissions:18.63' // 下拉控件 implementation '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' + //implementation 'com.github.open-android:pinyin4j:2.5.0' // SSH - implementation 'com.jcraft:jsch:0.1.55' + //implementation 'com.jcraft:jsch:0.1.55' // Html 解析 - implementation 'org.jsoup:jsoup:1.13.1' + //implementation 'org.jsoup:jsoup:1.13.1' // 二维码类库 implementation 'com.google.zxing:core:3.4.1' implementation 'com.journeyapps:zxing-android-embedded:3.6.0' // 应用介绍页类库 - implementation 'io.github.medyo:android-about-page:2.0.0' + //implementation 'io.github.medyo:android-about-page:2.0.0' // 吐司类库 - implementation 'com.github.getActivity:ToastUtils:10.5' + //implementation 'com.github.getActivity:ToastUtils:10.5' // 网络连接类库 implementation 'com.squareup.okhttp3:okhttp:4.4.1' - // Android 类库 + // AndroidX 类库 implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.viewpager:viewpager:1.0.0' implementation 'androidx.vectordrawable:vectordrawable:1.1.0' implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0' implementation 'androidx.fragment:fragment:1.1.0' - implementation 'com.google.android.material:material:1.4.0' - - implementation 'cc.winboll.studio:libappbase:2.1.5' - implementation 'cc.winboll.studio:libapputils:9.4.4' - implementation 'cc.winboll.studio:libaes:7.6.12' + implementation 'com.google.android.material:material:1.3.0' + + implementation 'cc.winboll.studio:libappbase:15.0.5' + implementation 'cc.winboll.studio:libapputils:15.0.7' } diff --git a/positions/build.properties b/positions/build.properties index 13fb0af..e26f996 100644 --- a/positions/build.properties +++ b/positions/build.properties @@ -1,8 +1,8 @@ #Created by .winboll/winboll_app_build.gradle -#Tue Mar 11 03:01:39 GMT 2025 +#Wed Mar 19 21:14:00 GMT 2025 stageCount=0 libraryProject= baseVersion=1.0 publishVersion=1.0.0 -buildCount=254 +buildCount=256 baseBetaVersion=1.0.1 diff --git a/positions/src/.DS_Store b/positions/src/.DS_Store deleted file mode 100644 index 9d6a566..0000000 Binary files a/positions/src/.DS_Store and /dev/null differ diff --git a/positions/src/main/.DS_Store b/positions/src/main/.DS_Store deleted file mode 100644 index d381763..0000000 Binary files a/positions/src/main/.DS_Store and /dev/null differ diff --git a/positions/src/main/AndroidManifest.xml b/positions/src/main/AndroidManifest.xml index 5a919d4..8ba3a8c 100644 --- a/positions/src/main/AndroidManifest.xml +++ b/positions/src/main/AndroidManifest.xml @@ -35,6 +35,8 @@ + tools:ignore="AllowBackup,GoogleAppIndexingWarning"> diff --git a/positions/src/main/java/.DS_Store b/positions/src/main/java/.DS_Store deleted file mode 100644 index 35a54bf..0000000 Binary files a/positions/src/main/java/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/cc/winboll/studio/positions/App.java b/positions/src/main/java/cc/winboll/studio/positions/App.java index 506b8eb..a4048dc 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/App.java +++ b/positions/src/main/java/cc/winboll/studio/positions/App.java @@ -7,7 +7,6 @@ package cc.winboll.studio.positions; */ import cc.winboll.studio.libappbase.GlobalApplication; import cc.winboll.studio.libappbase.LogUtils; -import cc.winboll.studio.libapputils.app.WinBollActivityManager; public class App extends GlobalApplication { @@ -20,7 +19,7 @@ public class App extends GlobalApplication { setIsDebuging(this, BuildConfig.DEBUG); super.onCreate(); // 设置 WinBoll 应用 UI 类型 - WinBollActivityManager.getInstance(this).setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Aplication); + //WinBollActivityManager.getInstance(this).setWinBollUI_TYPE(WinBollActivityManager.WinBollUI_TYPE.Aplication); LogUtils.d(TAG, "onCreate"); diff --git a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java index 5e56b02..fa63b36 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/MainActivity.java @@ -15,7 +15,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentPagerAdapter; @@ -36,10 +35,12 @@ import cc.winboll.studio.positions.fragments.PositionsFragment; import cc.winboll.studio.positions.fragments.TXMSFragment; import cc.winboll.studio.positions.fragments.TasksFragment; import com.google.android.material.tabs.TabLayout; -import com.hjq.toast.ToastUtils; -import com.tencent.map.vector.demo.AbsActivity; +//import com.hjq.toast.ToastUtils; import java.util.ArrayList; import java.util.List; +import cc.winboll.studio.positions.activities.AbsActivity; +import android.widget.Toolbar; +import cc.winboll.studio.libappbase.utils.ToastUtils; final public class MainActivity extends AbsActivity implements IWinBollActivity, ViewPager.OnPageChangeListener, View.OnClickListener { @@ -67,10 +68,6 @@ final public class MainActivity extends AbsActivity implements IWinBollActivity, private static final int DIALER_REQUEST_CODE = 1; - @Override - public AppCompatActivity getActivity() { - return this; - } @Override public APPInfo getAppInfo() { @@ -101,12 +98,12 @@ final public class MainActivity extends AbsActivity implements IWinBollActivity, // 初始化工具栏 mToolbar = findViewById(R.id.toolbar); - setSupportActionBar(mToolbar); + setActionBar(mToolbar); // if (isEnableDisplayHomeAsUp()) { // // 显示后退按钮 // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } - getSupportActionBar().setTitle(""); + getActionBar().setTitle(""); // 初始化地图视图 // 创建Fragment实例 @@ -279,23 +276,23 @@ final public class MainActivity extends AbsActivity implements IWinBollActivity, @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) { @@ -315,8 +312,8 @@ final public class MainActivity extends AbsActivity implements IWinBollActivity, 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_positionnow) { mTXMSFragment.sendRealTimePositioningMessage(); diff --git a/positions/src/main/java/cc/winboll/studio/positions/MainSimpleActivity.java b/positions/src/main/java/cc/winboll/studio/positions/MainSimpleActivity.java index 39eab31..be79268 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/MainSimpleActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/MainSimpleActivity.java @@ -52,9 +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 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"; @@ -114,34 +114,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 +161,10 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss // 读取数据 locationJsonList = LocationFileStorage.loadFromFile(this); - for (PostionModel 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) { @@ -215,13 +215,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 +246,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 +431,15 @@ public class MainSimpleActivity extends AppCompatActivity implements EasyPermiss locationChangedListener = null; } - @Override - public void onPermissionsGranted(int requestCode, @NonNull List perms) { - Log.e("location quest: ", "success"); - } - - @Override - public void onPermissionsDenied(int requestCode, @NonNull List perms) { - Log.e("location quest: ", "failed"); - } +// @Override +// public void onPermissionsGranted(int requestCode, @NonNull List perms) { +// Log.e("location quest: ", "success"); +// } +// +// @Override +// public void onPermissionsDenied(int requestCode, @NonNull List perms) { +// Log.e("location quest: ", "failed"); +// } private void checkLocationPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED diff --git a/positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/activities/AbsActivity.java similarity index 96% rename from positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java rename to positions/src/main/java/cc/winboll/studio/positions/activities/AbsActivity.java index d7a3eb6..fb34259 100644 --- a/positions/src/main/java/com/tencent/map/vector/demo/AbsActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/activities/AbsActivity.java @@ -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; diff --git a/positions/src/main/java/cc/winboll/studio/positions/activities/SettingsActivity.java b/positions/src/main/java/cc/winboll/studio/positions/activities/SettingsActivity.java index 8bca04d..e7dab22 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/activities/SettingsActivity.java +++ b/positions/src/main/java/cc/winboll/studio/positions/activities/SettingsActivity.java @@ -16,12 +16,12 @@ import android.view.WindowManager; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; import cc.winboll.studio.libapputils.app.IWinBollActivity; import cc.winboll.studio.libapputils.bean.APPInfo; import cc.winboll.studio.positions.R; -import com.hjq.toast.ToastUtils; import java.lang.reflect.Field; +import android.widget.Toolbar; +import cc.winboll.studio.libappbase.utils.ToastUtils; public class SettingsActivity extends AppCompatActivity implements IWinBollActivity { @@ -34,10 +34,6 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv return null; } - @Override - public AppCompatActivity getActivity() { - return this; - } @Override public String getTag() { @@ -66,12 +62,12 @@ public class SettingsActivity extends AppCompatActivity implements IWinBollActiv // 初始化工具栏 mToolbar = findViewById(R.id.activitymainToolbar1); - setSupportActionBar(mToolbar); + setActionBar(mToolbar); if (isEnableDisplayHomeAsUp()) { // 显示后退按钮 - getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getActionBar().setDisplayHomeAsUpEnabled(true); } - getSupportActionBar().setSubtitle(getTag()); + getActionBar().setSubtitle(getTag()); } diff --git a/positions/src/main/java/cc/winboll/studio/positions/fragments/TXMSFragment.java b/positions/src/main/java/cc/winboll/studio/positions/fragments/TXMSFragment.java index 27ad211..a00c87f 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/fragments/TXMSFragment.java +++ b/positions/src/main/java/cc/winboll/studio/positions/fragments/TXMSFragment.java @@ -33,7 +33,6 @@ import androidx.fragment.app.Fragment; import cc.winboll.studio.libappbase.LogUtils; import cc.winboll.studio.positions.beans.PostionModel; import cc.winboll.studio.positions.utils.LocationFileStorage; -import com.hjq.toast.ToastUtils; import com.tencent.map.geolocation.TencentLocation; import com.tencent.map.geolocation.TencentLocationListener; import com.tencent.map.geolocation.TencentLocationManager; @@ -54,9 +53,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.libappbase.utils.ToastUtils; -public class TXMSFragment extends Fragment implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener { +public class TXMSFragment extends Fragment implements /*EasyPermissions.PermissionCallbacks,*/LocationSource, TencentLocationListener { public static final String TAG = "TXMSFragment"; @@ -355,15 +354,15 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission private void moveToLocation(Location location) { ToastUtils.show(String.format("%s", location.toString())); - //对地图操作类进行操作 - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - convertToLatLng(location), - 15, - 0f, - 0f)); - //移动地图 - tencentMap.moveCamera(cameraSigma); +// //对地图操作类进行操作 +// CameraUpdate cameraSigma = +// CameraUpdateFactory.newCameraPosition(new CameraPosition( +// convertToLatLng(location), +// 15, +// 0f, +// 0f)); +// //移动地图 +// tencentMap.moveCamera(cameraSigma); //addLocationToMap(location); } @@ -400,14 +399,14 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission public void run() { //对地图操作类进行操作 - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - convertToLatLng(location), - 15, - 0f, - 0f)); - //移动地图 - tencentMap.moveCamera(cameraSigma); +// CameraUpdate cameraSigma = +// CameraUpdateFactory.newCameraPosition(new CameraPosition( +// convertToLatLng(location), +// 15, +// 0f, +// 0f)); +// //移动地图 +// tencentMap.moveCamera(cameraSigma); // Rules.getEffectInfo(location); // double distance = DistanceUtils.getDistance( // locationA.getLatitude(), @@ -477,15 +476,6 @@ public class TXMSFragment extends Fragment implements EasyPermissions.Permission locationChangedListener = null; } - @Override - public void onPermissionsGranted(int requestCode, @NonNull List perms) { - Log.e("location quest: ", "success"); - } - - @Override - public void onPermissionsDenied(int requestCode, @NonNull List perms) { - Log.e("location quest: ", "failed"); - } private void checkLocationPermission() { if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED diff --git a/positions/src/main/java/cc/winboll/studio/positions/fragments/TasksFragment.java b/positions/src/main/java/cc/winboll/studio/positions/fragments/TasksFragment.java index aca7911..8e8b5c6 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/fragments/TasksFragment.java +++ b/positions/src/main/java/cc/winboll/studio/positions/fragments/TasksFragment.java @@ -16,7 +16,8 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import cc.winboll.studio.positions.R; -import com.hjq.toast.ToastUtils; +import cc.winboll.studio.libappbase.utils.ToastUtils; +//import com.hjq.toast.ToastUtils; public class TasksFragment extends Fragment { diff --git a/positions/src/main/java/cc/winboll/studio/positions/receivers/MainReceiver.java b/positions/src/main/java/cc/winboll/studio/positions/receivers/MainReceiver.java index d3daaa5..3773a0f 100644 --- a/positions/src/main/java/cc/winboll/studio/positions/receivers/MainReceiver.java +++ b/positions/src/main/java/cc/winboll/studio/positions/receivers/MainReceiver.java @@ -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 { diff --git a/positions/src/main/java/com/.DS_Store b/positions/src/main/java/com/.DS_Store deleted file mode 100644 index 5115a43..0000000 Binary files a/positions/src/main/java/com/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/com/tencent/.DS_Store b/positions/src/main/java/com/tencent/.DS_Store deleted file mode 100644 index 1ec5418..0000000 Binary files a/positions/src/main/java/com/tencent/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/com/tencent/map/.DS_Store b/positions/src/main/java/com/tencent/map/.DS_Store deleted file mode 100644 index 5948dff..0000000 Binary files a/positions/src/main/java/com/tencent/map/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/com/tencent/map/vector/.DS_Store b/positions/src/main/java/com/tencent/map/vector/.DS_Store deleted file mode 100644 index 8067953..0000000 Binary files a/positions/src/main/java/com/tencent/map/vector/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/com/tencent/map/vector/demo/.DS_Store b/positions/src/main/java/com/tencent/map/vector/demo/.DS_Store deleted file mode 100644 index e7a62d4..0000000 Binary files a/positions/src/main/java/com/tencent/map/vector/demo/.DS_Store and /dev/null differ diff --git a/positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java deleted file mode 100644 index 22327e3..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/AbsListActivity.java +++ /dev/null @@ -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))); - } - }); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java deleted file mode 100644 index f8c8231..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/AbsMapActivity.java +++ /dev/null @@ -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); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java deleted file mode 100644 index 3497d79..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/DemoMainActivity.java +++ /dev/null @@ -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 mDemoTypes; - private static Map> 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 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 { - - private int mType; - - DemoActivityAdapter(String type) { - super(new DiffUtil.ItemCallback() { - @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 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(); - } - } - }); - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java deleted file mode 100644 index cc8d899..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorFloorView.java +++ /dev/null @@ -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 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; - } - - /** - * 修改偏移量,即当第一个显示在中间是上面有几个空白
- * 也会影响整体显示,如设置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 getItems() { - return items; - } - - /** - * 设置显示的内容 - * - * @param list - */ - public void setItems(List list) { - if (null == items) { - items = new ArrayList(); - } - 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(); - } - - 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; - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java deleted file mode 100644 index df4a37c..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/IndoorMapActivity.java +++ /dev/null @@ -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 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 markerClusterClusterManager = new ClusterManager(this, tencentMap); - NonHierarchicalDistanceBasedAlgorithm nba = new NonHierarchicalDistanceBasedAlgorithm<>(this); - nba.setMaxDistanceAtZoom(15); - markerClusterClusterManager.setAlgorithm(nba); - DefaultClusterRenderer 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 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 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; - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java deleted file mode 100644 index de4b063..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapRenderLayerActivity.java +++ /dev/null @@ -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(); - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java deleted file mode 100644 index d8a94e0..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapStyleDemoActivity.java +++ /dev/null @@ -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 adapter = new ArrayAdapter(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); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java deleted file mode 100644 index b7ef6d0..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/MapViewActivity.java +++ /dev/null @@ -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(); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java deleted file mode 100644 index d7180eb..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/OfflineMapActivity.java +++ /dev/null @@ -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 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 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 { -// -// List offlineItems; -// -// OfflineAdapter(List 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 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 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 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(); -// } -// -//} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java deleted file mode 100644 index da85478..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/OverseaMapActivity.java +++ /dev/null @@ -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; - } - } -} - diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java deleted file mode 100644 index 100b835..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/RecyclerListActivity.java +++ /dev/null @@ -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 { - private List 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(); - } - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java deleted file mode 100644 index 464facb..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/SetMapTypeActivity.java +++ /dev/null @@ -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; - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java deleted file mode 100644 index 472e707..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/SupportMapFragmentActivity.java +++ /dev/null @@ -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); - - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java deleted file mode 100644 index 890682e..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/basic/UiSettingsActivity.java +++ /dev/null @@ -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); - } - } - }); - - - - - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java deleted file mode 100644 index 3c2a501..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapAnchorZoomActivity.java +++ /dev/null @@ -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); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java deleted file mode 100644 index 9d7a878..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapBoundActivity.java +++ /dev/null @@ -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{ - - } - } - }); - } - - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java deleted file mode 100644 index 91d3cd5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/camera/MapCameraCenterActivity.java +++ /dev/null @@ -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))); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java deleted file mode 100644 index c503d58..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/circle/ArcActivity.java +++ /dev/null @@ -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(); - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java deleted file mode 100644 index d1ec760..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/circle/CircleOptionsActivity.java +++ /dev/null @@ -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); -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java deleted file mode 100644 index f9a1cf3..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/circle/DrawCircleActivity.java +++ /dev/null @@ -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)); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java deleted file mode 100644 index 80e0942..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/gesture/GestureSettingsActivity.java +++ /dev/null @@ -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); - } - } - }); - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java deleted file mode 100644 index 046074c..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapGestureListenActivity.java +++ /dev/null @@ -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; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java deleted file mode 100644 index 8bb6f50..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapListenActivity.java +++ /dev/null @@ -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); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java deleted file mode 100644 index f1cc9c4..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/gesture/MapLongClickActivity.java +++ /dev/null @@ -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; - } - - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java deleted file mode 100644 index cab7cf7..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/AggregationOverlayActivity.java +++ /dev/null @@ -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 nodes = new ArrayList(); - 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(); - } - } - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java deleted file mode 100644 index 24d1bc8..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ArcLineLayerActivity.java +++ /dev/null @@ -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 nodes = new ArrayList(); - 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); - - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java deleted file mode 100644 index 20e246e..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawHeatOverlayActivity.java +++ /dev/null @@ -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 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(); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java deleted file mode 100644 index d84558f..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/DrawOldVersionHeatOverlayActivity.java +++ /dev/null @@ -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 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 getHeatDataNodes(){ -// //HeatDataNode 是热力图热点,包括热点位置和热度值(HeatOverlay会根据传入的全部节点的热度值范围计算最终的颜色表现) -// ArrayList 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 transferHeatNodes(ArrayList nodes){ -// ArrayList newNodes = new ArrayList(); -// 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; -// } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java deleted file mode 100644 index 466e5d5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/GLModelActivity.java +++ /dev/null @@ -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 adapter = new ArrayAdapter(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(); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java deleted file mode 100644 index 0036536..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/HeatMapVectorOverlayActivity.java +++ /dev/null @@ -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 nodes = new ArrayList(); - 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(); - } - } - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java deleted file mode 100644 index d56cc37..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/ScatterPlotOverlayActivity.java +++ /dev/null @@ -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 adapter = new ArrayAdapter(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 nodes = new ArrayList(); - 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 nodes = new ArrayList(); - 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); - } - - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java deleted file mode 100644 index 5ca3dfe..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/TrailOverlayActivity.java +++ /dev/null @@ -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 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); - - - } - - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java deleted file mode 100644 index d62ab21..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/heatoverlay/VectorHeatMapActivity.java +++ /dev/null @@ -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 getHeatNodes() { - BufferedReader br = null; - ArrayList 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; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java deleted file mode 100644 index aeb6339..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationLayerActivity.java +++ /dev/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 perms) { - Log.e("location quest: ", "success"); - } - - @Override - public void onPermissionsDenied(int requestCode, @NonNull List 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; - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java deleted file mode 100644 index b841353..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/location/LocationPointActivity.java +++ /dev/null @@ -1,190 +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.Bundle; -import android.os.Looper; -import androidx.annotation.NonNull; -import android.util.Log; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -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.model.BitmapDescriptor; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle; - -import java.util.List; - -import pub.devrel.easypermissions.EasyPermissions; - -public class LocationPointActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks,LocationSource, TencentLocationListener{ - private LocationSource.OnLocationChangedListener locationChangedListener; - - private TencentLocationManager locationManager; - private TencentLocationRequest locationRequest; - private MyLocationStyle locationStyle; - - @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); - } - //设置显示定位的图标 - TencentLocationManager.setUserAgreePrivacy(true); - //建立定位 - initLocation(); - } - - - /** - * 设置定位图标样式 - */ - private void setLocMarkerStyle(){ - locationStyle = new MyLocationStyle(); - //创建图标 - BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); - locationStyle.icon(bitmapDescriptor); - //设置定位圆形区域的边框宽度 - locationStyle.strokeWidth(3); - //设置圆区域的颜色 - locationStyle.fillColor(R.color.style); - - tencentMap.setMyLocationStyle(locationStyle); - } - - - - 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; - } - - - - /** - * 定位的一些初始化设置 - */ - 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); - } - /** - * 实现位置监听 - * @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 perms) { - Log.e("location quest: ","success"); - } - - @Override - public void onPermissionsDenied(int requestCode, @NonNull List perms) { - Log.e("location quest: ","failed"); - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java deleted file mode 100644 index d9479b3..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/AoiLayerActivity.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.RelativeLayout; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -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.AoiLayer; -import com.tencent.tencentmap.mapsdk.maps.model.AoiLayerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.MapPoi; -import com.tencent.tencentmap.mapsdk.maps.model.SubPoi; - -public class AoiLayerActivity extends AppCompatActivity implements AoiLayer.OnAoiLayerLoadListener { - private MapView mMapView; - private RelativeLayout mRelativeLayout; - private TencentMap mTencentMap; - private boolean mIsSelected; - private AoiLayer mAoiLayer; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_aoi_layer); - mRelativeLayout = findViewById(R.id.relativelayout); - TencentMapOptions options = new TencentMapOptions(); - mMapView = new MapView(this, options); - mRelativeLayout.addView(mMapView); - mTencentMap = mMapView.getMap(); - } - - @Override - protected void onStart() { - super.onStart(); - mMapView.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - mMapView.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - mMapView.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - mMapView.onStop(); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - mMapView.onDestroy(); - } - - @Override - public void onAoiLayerLoaded(boolean b, AoiLayer aoiLayer) { - - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.marker_groundoverlay, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add_groundoverlay).setVisible(!mIsSelected); - menu.findItem(R.id.menu_remove_groundoverlay).setVisible(mIsSelected); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_add_groundoverlay: - addAOI(); - break; - case R.id.menu_remove_groundoverlay: - removeAOI(); - break; - } - - supportInvalidateOptionsMenu(); - return super.onOptionsItemSelected(item); - } - - /** - * 添加AOI面 - */ - private void addAOI() { - mIsSelected = true; - //通过检索能力获取Poi的ID ,以北京大学为例 - String poiId = "11107399966856067949"; - //AOI面配置项 - AoiLayerOptions options = new AoiLayerOptions(); - //设置显示级别 有效范围是(0-20] - options.setDisplayLevel(10, 20); - - //添加一个Aoi面 - mAoiLayer = mTencentMap.addAoiLayer(poiId, options, new AoiLayer.OnAoiLayerLoadListener() { - - @Override - public void onAoiLayerLoaded(boolean b, AoiLayer aoiLayer) { - if (b) { - Toast.makeText(AoiLayerActivity.this, "添加[" + aoiLayer.name() + "]成功!", Toast.LENGTH_LONG).show(); - } else { - Toast.makeText(AoiLayerActivity.this, "添加[" + aoiLayer.getId() + "]失败!", Toast.LENGTH_LONG).show(); - } - } - }); - - //设置AOi面上的子POI点的点击回调 - mTencentMap.setOnMapPoiClickListener(new TencentMap.OnMapPoiClickListener() { - - @Override - public void onClicked(MapPoi mapPoi) { - if (mapPoi instanceof SubPoi) { - Toast.makeText(AoiLayerActivity.this, "SubPoi[" + mapPoi.getName() + "]被点击!", Toast.LENGTH_LONG).show(); - } - } - }); - - } - - /** - * 移除AOI面 - */ - private void removeAOI() { - mIsSelected = false; - if (mAoiLayer != null) { - mAoiLayer.remove(); - } - } -} - - diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java deleted file mode 100644 index 576efa5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/CustomRenderActivity.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import androidx.appcompat.app.AppCompatActivity; - -import android.graphics.PointF; -import android.opengl.GLES20; -import android.os.Bundle; -import android.util.Log; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.CustomRender; -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.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.nio.ShortBuffer; - -/** - * OpenGL绘制 - */ -public class CustomRenderActivity extends AppCompatActivity { - - private static final String TAG = CustomRenderActivity.class.getSimpleName(); - - // 标识是否第一次绘制3D立方体 - private boolean mIsFirstDraw3DCube = true; - - // 立方体8个顶点坐标 - private float[] mVertices = { - -1, -1, -0, - 1, -1, -0, - 1, 1, -0, - -1, 1, -0, - -1, -1, 1, - 1, -1, 1, - 1, 1, 1, - -1, 1, 1, - }; - - // 3D立方体顶点绘制顺序列表 - private short[] mDrawIndices = { - 5, 4, 0, 1, 5, 0, 6, 5, 1, 2, 6, 1, - 7, 6, 2, 3, 7, 2, 4, 7, 3, 0, 4, 3, - 6, 7, 4, 5, 6, 4, 1, 0, 3, 2, 1, 3 - }; - - // 3D立方体8个顶点颜色值 - private float[] mVertexColors = { - 1f, 1f, 0f, 1f, - 0f, 1f, 1f, 1f, - 1f, 0f, 1f, 1f, - 0f, 0f, 0f, 1f, - 1f, 1f, 1f, 1f, - 1f, 0f, 0f, 1f, - 0f, 1f, 0f, 1f, - 0f, 0f, 1f, 1f - }; - - // 立方体顶点坐标Buffer - private FloatBuffer mVertexBuffer; - - // 顶点绘制顺序Buffer - private ShortBuffer mIndexBuffer; - - // 立方体顶点颜色Buffer - private FloatBuffer mColorBuffer; - - // 3D立方体着色器 - private CubeShader mCubeShader; - - private MapView mapView; - - private TencentMap mMap; - - private LatLng latlng = new LatLng(40.04199816,116.27479076); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_custom_render); - mapView = findViewById(R.id.map_view); - mMap = mapView.getMap(); - mMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { - @Override - public void onMapLoaded() { - mMap.setCustomRender(new CubeRender()); - mMap.removeOnMapLoadedCallback(this); - } - }); - - mMap.moveCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder() - .target(latlng).zoom(16).tilt(45).build())); - - - } - - @Override - protected void onResume() { - // TODO Auto-generated method stub - super.onResume(); - mapView.onResume(); - } - - @Override - protected void onDestroy() { - // TODO Auto-generated method stub - super.onDestroy(); - mapView.onDestroy(); - } - - private class CubeRender implements CustomRender { - - private void initCubeData(float width, float height, float depth) { - // 对标地图坐标 - initVertices(mVertices, width, height, depth); - - // 立方体顶点数据Buffer - mVertexBuffer = ByteBuffer.allocateDirect(mVertices.length * 4) - .order(ByteOrder.nativeOrder()) - .asFloatBuffer(); - mVertexBuffer.put(mVertices).position(0); - - // 立方体顶点绘制顺序Buffer - ByteBuffer byteBuffer = ByteBuffer.allocateDirect(mDrawIndices.length * 4); - byteBuffer.order(ByteOrder.nativeOrder()); - mIndexBuffer = byteBuffer.asShortBuffer(); - mIndexBuffer.put(mDrawIndices); - mIndexBuffer.position(0); - - // 立方体顶点颜色Buffer - ByteBuffer byteBuffer1 = ByteBuffer.allocateDirect(mVertexColors.length * 4); - byteBuffer1.order(ByteOrder.nativeOrder()); - mColorBuffer = byteBuffer1.asFloatBuffer(); - mColorBuffer.put(mVertexColors); - mColorBuffer.position(0); - } - - private void initCubeShader() { - mCubeShader = new CubeShader(); - mCubeShader.init(); - } - - private void initVertices(float[] vertices, float width, float height, float depth) { - for (int i = 0; i < vertices.length / 3; i++) { - int m = i * 3; - vertices[m] = vertices[m] * width; - vertices[m + 1] = vertices[m + 1] * height; - vertices[m + 2] = vertices[m + 2] * depth; - } - } - - @Override - public void onDrawFrame() { - drawCube(); - } - - private void drawCube() { - - if (mIsFirstDraw3DCube) { - float cubeWidth = 0.2f * 10000 / 2; - float cubeHeight = 0.2f * 10000 / 2; - float cubeDepth = 0.4f * 10000 / 2; - initCubeData(cubeWidth, cubeHeight, cubeDepth); - initCubeShader(); - mIsFirstDraw3DCube = false; - } - - if (null == mCubeShader) { - return; - } - - // 绑定地图移动 - PointF p1f = mMap.getProjection().glVertexForCoordinate(latlng); - float[] mvpMatrix = mMap.getProjection().glModelMatrix(p1f, 1); - - // Step2 开始绘制设置 - GLES20.glUseProgram(mCubeShader.mProgram); - checkGlError("glUseProgram"); - - GLES20.glEnable(GLES20.GL_DEPTH_TEST); - checkGlError("glEnable"); - - //对齐矩阵 - GLES20.glUniformMatrix4fv(mCubeShader.mMvpMatrix, 1, false, mvpMatrix, 0); - checkGlError("glUniformMatrix4fv"); - - GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); - // 顶点指针 - GLES20.glEnableVertexAttribArray(mCubeShader.mVertex); - checkGlError("glEnableVertexAttribArray"); - GLES20.glVertexAttribPointer(mCubeShader.mVertex, 3, GLES20.GL_FLOAT, false, 0, mVertexBuffer); - checkGlError("glVertexAttribPointer"); - - // 颜色指针 - GLES20.glEnableVertexAttribArray(mCubeShader.mColor); - checkGlError("glEnableVertexAttribArray"); - GLES20.glVertexAttribPointer(mCubeShader.mColor, 4, GLES20.GL_FLOAT, false, 0, mColorBuffer); - checkGlError("glVertexAttribPointer"); - - GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0); - // 开始画 - GLES20.glDrawElements(GLES20.GL_TRIANGLES, mDrawIndices.length, GLES20.GL_UNSIGNED_SHORT, mIndexBuffer); - checkGlError("glDrawElements"); - - GLES20.glDisableVertexAttribArray(mCubeShader.mVertex); - checkGlError("glDisableVertexAttribArray"); - - GLES20.glDisable(GLES20.GL_DEPTH_TEST); - checkGlError("glDisable"); - } - } - - private static class CubeShader { - int mVertex; - int mMvpMatrix; - int mColor; - int mProgram; - - String vertexShader = "precision mediump float;\n" + - " attribute vec3 mVertex;//顶点数组,三维坐标\n" + - " attribute vec4 mColor;//颜色数组,三维坐标\n" + - " uniform mat4 mMvpMatrix;//mvp矩阵\n" + - " varying vec4 color;//\n" + - " void main(){\n" + - " gl_Position = mMvpMatrix * vec4(mVertex, 1.0);\n" + - " color = mColor;\n" + - " }"; - - String fragmentShader = "//有颜色 没有纹理\n" + - " precision mediump float;\n" + - " varying vec4 color;//\n" + - " void main(){\n" + - " gl_FragColor = color;\n" + - " }"; - - public void init() { - int vertexLocation = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER); - GLES20.glShaderSource(vertexLocation, vertexShader); - checkGlError("glShaderSource"); - GLES20.glCompileShader(vertexLocation); - checkGlError("glCompileShader"); - int fragmentLocation = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER); - GLES20.glShaderSource(fragmentLocation, fragmentShader); - checkGlError("glShaderSource"); - GLES20.glCompileShader(fragmentLocation); - checkGlError("glCompileShader"); - - mProgram = GLES20.glCreateProgram(); - GLES20.glAttachShader(mProgram, vertexLocation); - GLES20.glAttachShader(mProgram, fragmentLocation); - GLES20.glLinkProgram(mProgram); - int[] linked = new int[1]; - GLES20.glGetProgramiv(mProgram, GLES20.GL_LINK_STATUS, linked, 0); - checkGlError("glLinkProgram"); - if (linked[0] != GLES20.GL_TRUE) { - Log.e(TAG, "Could not link program: "); - Log.e(TAG, GLES20.glGetProgramInfoLog(mProgram)); - GLES20.glDeleteProgram(mProgram); - mProgram = 0; - } - - - mVertex = GLES20.glGetAttribLocation(mProgram, "mVertex"); - mMvpMatrix = GLES20.glGetUniformLocation(mProgram, "mMvpMatrix"); - mColor = GLES20.glGetAttribLocation(mProgram, "mColor"); - } - - } - - static void checkGlError(String op) { - int error; - while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) { - Log.e(TAG, op + ": glError " + error); - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java deleted file mode 100644 index 8f50b24..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/GroundOverlayActivity.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.fragment.app.FragmentActivity; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.Button; -import android.widget.RadioGroup; - - -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.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlay; -import com.tencent.tencentmap.mapsdk.maps.model.GroundOverlayOptions; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.OverlayLevel; - -import java.util.ArrayList; - -public class GroundOverlayActivity extends SupportMapFragmentActivity { - - private MapView mMapView; - private TencentMap mTencentMap; - private GroundOverlay groundOverlay; - GroundOverlayOptions groundOverlayOptions; - private boolean mIsSelected; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_ground_overlay); - mMapView = findViewById(R.id.map_view); - mTencentMap = mMapView.getMap(); - mTencentMap.setIndoorEnabled(true); - } - - - @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 boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.marker_groundoverlay, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add_groundoverlay).setVisible(!mIsSelected); - menu.findItem(R.id.menu_remove_groundoverlay).setVisible(mIsSelected); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_add_groundoverlay: - addGroundOverlays(); - break; - case R.id.menu_remove_groundoverlay: - removeGroundOverlays(); - break; - } - - supportInvalidateOptionsMenu(); - return super.onOptionsItemSelected(item); - } - - public void addGroundOverlays() { - mIsSelected = true; - LatLngBounds lb = new LatLngBounds( - new LatLng(40.045226, 116.280069), - new LatLng(40.038918, 116.271873)); - groundOverlayOptions = new GroundOverlayOptions() - .bitmap(BitmapDescriptorFactory - .fromAsset("groundoverlay.jpg")) - .latLngBounds(lb) - .alpha(10); - groundOverlay = mTencentMap.addGroundOverlay(groundOverlayOptions); - mTencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(lb, 300)); - - } - - public void removeGroundOverlays() { - mIsSelected = false; - if (groundOverlay != null) { - groundOverlay.remove(); - groundOverlay = null; - } - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java deleted file mode 100644 index 5e6338e..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerActivity.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -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.map.vector.demo.basic.SupportMapFragmentActivity; -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.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class MarkerActivity extends SupportMapFragmentActivity { - public Marker marker; - public Switch aSwitch; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - aSwitch = findViewById(R.id.switch_map); - aSwitch.setVisibility(View.VISIBLE); - aSwitch.setText("添加标注"); - setMarker(); - aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if(isChecked){ - setMarker(); - }else { - if(marker!=null){ - marker.remove(); - } - } - } - }); - - } - - /** - * 设置标注 - */ - private void setMarker(){ - LatLng latLng = new LatLng(39.984108,116.307557); - BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); - MarkerOptions options = new MarkerOptions().position(latLng).icon(bitmapDescriptor); - - //设置infowindow - options.title("地址"); - options.snippet("中国技术交易大厦"); - marker = tencentMap.addMarker(options); - marker.setInfoWindowEnable(true); - } - - - 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; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java deleted file mode 100644 index 22fe233..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerAnimation.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.graphics.Point; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.Interpolator; - -import androidx.annotation.Nullable; - -import com.tencent.map.vector.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; -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.IAlphaAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.IAnimationSet; -import com.tencent.tencentmap.mapsdk.maps.model.IRotateAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.IScaleAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.ITranslateAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; -import java.util.Timer; -import java.util.TimerTask; - -public class MarkerAnimation extends AbsMapActivity { - - private int rotate = 0; - private int scale = 1; - private int alpha = 2; - private int translate = 3; - private int set = 4; - private boolean mHasAdded; - private Marker marker; - private IRotateAnimation rotateAnimation; - private IScaleAnimation scaleAnimation; - private IAlphaAnimation alphaAnimation; - private ITranslateAnimation translateAnimation; - private TencentMap tencentMap; - private IAnimationSet animationSet; - private LatLng latLng; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { - super.onCreate(savedInstanceState, mTencentMap); - tencentMap = mTencentMap; - tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.marker_animation, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); - menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_add_marker_rotate: - tencentMap.clear(); - marker = tencentMap.addMarker(setMarkerAnimation(rotate)); - mHasAdded = true; - marker.setAnimation(rotateAnimation); - marker.startAnimation(); - break; - - case R.id.menu_add_marker_scale: - tencentMap.clear(); - marker = tencentMap.addMarker(setMarkerAnimation(scale)); - mHasAdded = true; - marker.setAnimation(scaleAnimation); - marker.startAnimation(); - scaleAnimation.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart() { - - } - - @Override - public void onAnimationEnd() { - marker.startAnimation(); - } - }); - - - break; - case R.id.menu_add_marker_alpha: - tencentMap.clear(); - marker = tencentMap.addMarker(setMarkerAnimation(alpha)); - mHasAdded = true; - marker.setAnimation(alphaAnimation); - marker.startAnimation(); - break; - case R.id.menu_add_marker_translate: - tencentMap.clear(); - marker = tencentMap.addMarker(setMarkerAnimation(translate)); - mHasAdded = true; - Point screenLocation = tencentMap.getProjection().toScreenLocation(latLng); - - marker.setFixingPoint(screenLocation.x, screenLocation.y); - - marker.setAnimation(translateAnimation); - marker.startAnimation(); - - translateAnimation.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart() { - - } - - @Override - public void onAnimationEnd() { - marker.setFixingPointEnable(false); - - } - }); - break; - case R.id.menu_add_marker_set: - tencentMap.clear(); - marker = tencentMap.addMarker(setMarkerAnimation(set)); - mHasAdded = true; - marker.setAnimation(animationSet); - marker.startAnimation(); - break; - - case R.id.menu_delete_marker: - if (marker != null) { - marker.remove(); - marker = null; - mHasAdded = false; - } - break; - } - return super.onOptionsItemSelected(item); - } - - private MarkerOptions setMarkerAnimation(int type) { - latLng = new LatLng(39.984108, 116.307557); - BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)); - MarkerOptions position = new MarkerOptions().position(latLng).icon(bitmapDescriptor); - switch (type) { - case 0: - //旋转动画 - rotateAnimation = tencentMap.getMapContext().createRotateAnimation(0, 360, 0, 0, 0); - rotateAnimation.setDuration(2000); - break; - case 1: - //缩放动画 - scaleAnimation = tencentMap.getMapContext().createScaleAnimation(0.0f, 1f, 0.0f, 1f); - scaleAnimation.setDuration(2000); - scaleAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); - - case 2: - //渐变 - alphaAnimation = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); - alphaAnimation.setDuration(2000); - alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); - - break; - case 3: - //平移 - Point point = tencentMap.getProjection().toScreenLocation(latLng); - point.y -= dip2px(this, 250); - LatLng target = tencentMap.getProjection().fromScreenLocation(point); - translateAnimation = tencentMap.getMapContext().createTranslateAnimation(target); - translateAnimation.setInterpolator(new Interpolator() { - @Override - public float getInterpolation(float v) { - if (v <= 0.5f) { - return (float) (0.5f - 2 * (0.5 - v) * (0.5 - v)); - } else { - return (float) (0.5f - Math.sqrt((v - 0.5f) * (1.5f - v))); - } - } - }); - translateAnimation.setDuration(2000); - break; - case 4: - //组合动画 - animationSet = tencentMap.getMapContext().createAnimationSet(true); - if (rotateAnimation != null || scaleAnimation != null || alphaAnimation != null) { - animationSet.addAnimation(rotateAnimation); - animationSet.addAnimation(scaleAnimation); - animationSet.addAnimation(alphaAnimation); - } - - break; - - default: - throw new IllegalStateException("Unexpected value: " + type); - } - return position; - } - - private static int dip2px(Context context, float dpValue) { - final float scale = context.getResources().getDisplayMetrics().density; - return (int) (dpValue * scale + 1.5f); - } - - 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; - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java deleted file mode 100644 index a6ddacf..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClickActivity.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.os.Bundle; -import android.view.View; -import android.widget.Toast; - -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; - -public class MarkerClickActivity extends MarkerActivity implements TencentMap.OnMarkerClickListener{ - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - marker.setInfoWindowEnable(false); - aSwitch.setVisibility(View.GONE); - tencentMap.setOnMarkerClickListener(this); - } - - @Override - public boolean onMarkerClick(Marker marker) { - Toast.makeText(getApplicationContext(),"您点击了标注", Toast.LENGTH_SHORT).show(); - return false; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java deleted file mode 100644 index b2b71f8..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerClusterActivity.java +++ /dev/null @@ -1,387 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.annotation.TargetApi; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.Point; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; - -import com.tencent.map.vector.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.map.vector.demo.utils.CoordinateActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.IAlphaAnimation; -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.PolygonOptions; -import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.Cluster; -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.ClusterRenderer; -import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer; -import com.tencent.tencentmap.mapsdk.vector.utils.ui.IconGenerator; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; - -public class MarkerClusterActivity extends AbsMapActivity { - private TencentMap tencentMap; - private boolean mHasAdded; - //点聚合坐标数据集合 - private List generalItemList = new ArrayList<>(); - private ClusterManager markerClusterItemClusterManager; - private int i = 8; - //自定义聚合 - private ClusterManager petaItemClusterManager; - private ArrayList petaItems; - private ArrayList latLngs; - private NonHierarchicalDistanceBasedAlgorithm ndba; - private DefaultClusterRenderer markerClusterItemDefaultClusterRenderer; - private String TAG="MarkerClusterActivity"; - - @Override - - protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap mTencentMap) { - super.onCreate(savedInstanceState, mTencentMap); - tencentMap = mTencentMap; - //tencentMap.enableMultipleInfowindow(true); - tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); - //默认聚合管理 - configDefaultCluterManger(); - configCustomCluterManger(); - petaItemClusterManager.setOnClusterClickListener(new ClusterManager.OnClusterClickListener() { - @Override - public boolean onClusterClick(Cluster cluster) { - Collection items = cluster.getItems(); - - return false; - } - }); - tencentMap.setOnCameraChangeListener(new TencentMap.OnCameraChangeListener() { - @Override - public void onCameraChange(CameraPosition cameraPosition) { - - } - - @Override - public void onCameraChangeFinished(CameraPosition cameraPosition) { - float zoom = cameraPosition.zoom; - if (zoom < 6) { - tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); - markerClusterItemClusterManager.addItems(getMassiveCoords()); - // tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(latLngs).build(), 20)); - markerClusterItemClusterManager.cluster(); - - } else { - markerClusterItemClusterManager.cancel(); - } - Log.d(TAG, "onCameraChangeFinished: " + zoom); - } - }); - } - - public class PetaItem implements ClusterItem { - private final LatLng mLatLng; - private int mDrawableResourceId; - - public PetaItem(double lat, double lon, int resourceId) { - mLatLng = new LatLng(lat, lon); - mDrawableResourceId = resourceId; - } - - @Override - public LatLng getPosition() { - return mLatLng; - } - - public int getDrawableResourceId() { - return mDrawableResourceId; - } - } - - //聚合设置 - private void configDefaultCluterManger() { - //实例化点聚合管理者 - markerClusterItemClusterManager = new ClusterManager<>(this, tencentMap); - //默认聚合策略,调用时不用添加,如果需要其它聚合策略可以按以下修改 - ndba = new NonHierarchicalDistanceBasedAlgorithm<>(this); - //设置点聚合距离 - ndba.setMaxDistanceAtZoom(35); - //设置策略 - markerClusterItemClusterManager.setAlgorithm(ndba); - //设置聚合渲染器,按照需要设置 - markerClusterItemDefaultClusterRenderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterItemClusterManager); - //设置最小聚合数量,默认是4 - markerClusterItemDefaultClusterRenderer.setMinClusterSize(5); - //定义聚合的分段,例如:当超过5个不满足10个数据,显示5+ - markerClusterItemDefaultClusterRenderer.setBuckets(new int[]{5, 10, 20, 50}); - markerClusterItemClusterManager.setRenderer(markerClusterItemDefaultClusterRenderer); - - - } - - //自定义聚合样式设置 - private void configCustomCluterManger() { - petaItemClusterManager = new ClusterManager<>(this, tencentMap); - CustomIconClusterRenderer customIconClusterRender = new CustomIconClusterRenderer(this, tencentMap, petaItemClusterManager); - customIconClusterRender.setMinClusterSize(3); - petaItemClusterManager.setRenderer(customIconClusterRender); - - } - - - //普通聚合 - private Collection getGeneralCoords() { - if (generalItemList == null || generalItemList.size() == 0) { - generalItemList = getItemWithFileName("cluster_new"); - } - return generalItemList; - } - - //海量聚合 - private Collection getMassiveCoords() { - if (generalItemList == null || generalItemList.size() == 0) { - generalItemList = getItemWithFileName("datab"); - } - return generalItemList; - } - - private List getItemWithFileName(String cluster_new) { - ArrayList arrayList = new ArrayList<>(); - latLngs = new ArrayList<>(); - try { - InputStream inputStream = getAssets().open(cluster_new); - InputStreamReader inputStreamReader = new InputStreamReader(inputStream); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String line; - while ((line = bufferedReader.readLine()) != null) { - String[] data = line.split("\t"); - double longitue = Double.parseDouble(data[0]); - double latitue = Double.parseDouble(data[1]); - arrayList.add(new MarkerClusterItem(latitue, longitue)); - latLngs.add(new LatLng(latitue, longitue)); - } - inputStream.close(); - inputStreamReader.close(); - bufferedReader.close(); - return arrayList; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.marker_cluster, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add_marker).setVisible(!mHasAdded); - menu.findItem(R.id.menu_delete_marker).setVisible(mHasAdded); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - tencentMap.setInfoWindowAdapter(new TencentMap.InfoWindowAdapter() { - @Override - public View getInfoWindow(Marker marker) { - LinearLayout inflate = (LinearLayout) View.inflate(getApplicationContext(), R.layout.custom_infowindow, null); - TextView title = inflate.findViewById(R.id.tv_title); - Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); - title.setText("\t\t\t\t\t\t\t\t自定义View弹窗:\n点在屏幕位置:" + point); - return inflate; - } - - @Override - public View getInfoContents(Marker marker) { - return null; - } - }); - final IAlphaAnimation alphaAnimation_custom = tencentMap.getMapContext().createAlphaAnimation(0f, 1f); - alphaAnimation_custom.setDuration(1000); - alphaAnimation_custom.setInterpolator(new AccelerateDecelerateInterpolator()); - tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { - @Override - public boolean onMarkerClick(Marker marker) { - Point point = tencentMap.getProjection().toScreenLocation(marker.getPosition()); - marker.setTitle(point.toString()); - marker.setAnimation(alphaAnimation_custom); - marker.startAnimation(); - return false; - } - }); - switch (item.getItemId()) { - case R.id.menu_add_marker_general: - mHasAdded = true; - //markerClusterItemClusterManager.cancel(); - tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); - markerClusterItemClusterManager.addItems(getGeneralCoords()); - LatLng position = generalItemList.get(6).getPosition(); - CameraUpdate cameraUpdate; - if (i < 16) { - i++; - cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); - } else { - i = 6; - cameraUpdate = CameraUpdateFactory.newLatLngZoom(position, i); - } - tencentMap.animateCamera(cameraUpdate); - markerClusterItemClusterManager.cluster(); - - break; - case R.id.menu_add_marker_massive: - mHasAdded = true; - tencentMap.setOnCameraChangeListener(markerClusterItemClusterManager); - markerClusterItemClusterManager.addItems(getMassiveCoords()); - - LatLng position_massive = generalItemList.get(60).getPosition(); - CameraUpdate cameraUpdate_massive; - if (i < 16) { - i++; - cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); - } else { - i = 6; - cameraUpdate_massive = CameraUpdateFactory.newLatLngZoom(position_massive, i); - } - tencentMap.animateCamera(cameraUpdate_massive); - markerClusterItemClusterManager.cluster(); - break; - case R.id.menu_add_marker_custom: - mHasAdded = true; - tencentMap.setOnCameraChangeListener(petaItemClusterManager); - addCustomClusterItem(); - tencentMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.971595, 116.314316), 15)); - petaItemClusterManager.cluster(); - break; - case R.id.menu_delete_marker: - mHasAdded = false; - clusterReMove(); - break; - - } - return super.onOptionsItemSelected(item); - } - - private void addCustomClusterItem() { - - petaItemClusterManager.addItem(new PetaItem(39.971595, 116.294747, R.mipmap.petal_blue)); - - petaItemClusterManager.addItem(new PetaItem(39.971595, 116.314316, R.mipmap.petal_red)); - - petaItemClusterManager.addItem(new PetaItem(39.967385, 116.317063, R.mipmap.petal_green)); - - petaItemClusterManager.addItem(new PetaItem(39.951596, 116.302300, R.mipmap.petal_yellow)); - - petaItemClusterManager.addItem(new PetaItem(39.970543, 116.290627, R.mipmap.petal_orange)); - - petaItemClusterManager.addItem(new PetaItem(39.966333, 116.311569, R.mipmap.petal_purple)); - } - - //移除聚合数据 - private void clusterReMove() { - markerClusterItemClusterManager.cancel(); - markerClusterItemClusterManager.cluster(); - generalItemList.clear(); - petaItemClusterManager.cancel(); - petaItemClusterManager.cluster(); - tencentMap.clearAllOverlays(); - - } - - class CustomIconClusterRenderer extends DefaultClusterRenderer { - - private IconGenerator mIconGenerator = new IconGenerator(getApplicationContext()); - private IconGenerator mClusterIconGenerator = new IconGenerator(getApplicationContext()); - private ImageView mItemImageView = new ImageView(getApplicationContext()); - private ImageView mClusterImageView = new ImageView(getApplicationContext()); - - public CustomIconClusterRenderer( - Context context, TencentMap map, ClusterManager clusterManager) { - super(context, map, clusterManager); - mItemImageView.setLayoutParams( - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - mIconGenerator.setContentView(mItemImageView); - - mClusterImageView.setLayoutParams( - new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - mClusterIconGenerator.setContentView(mClusterImageView); - - setMinClusterSize(1); - } - - @Override - public void onBeforeClusterRendered( - Cluster cluster, MarkerOptions markerOptions) { - int[] resources = new int[cluster.getItems().size()]; - int i = 0; - for (PetaItem item : cluster.getItems()) { - resources[i++] = item.getDrawableResourceId(); - } - - PetalDrawable drawable = new PetalDrawable(getApplicationContext(), resources); - mClusterImageView.setImageDrawable(drawable); - Bitmap icon = mClusterIconGenerator.makeIcon(); - markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); - } - - @Override - public void onBeforeClusterItemRendered(PetaItem item, MarkerOptions markerOptions) { - mItemImageView.setImageResource(item.getDrawableResourceId()); - Bitmap icon = mIconGenerator.makeIcon(); - markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)); - } - } - - class MarkerClusterItem implements ClusterItem { - private final LatLng mLatLng; - - public MarkerClusterItem(double lat, double lon) { - mLatLng = new LatLng(lat, lon); - } - - @Override - public LatLng getPosition() { - return mLatLng; - } - } -} - - diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java deleted file mode 100644 index 3a272c7..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerCollisions.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -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.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.MapPoi; -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 MarkerCollisions extends AppCompatActivity { - - private MapView mapView; - private TencentMap tencentMap; - private boolean mMarkerAdded; - private Marker mMarker; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_marker_collisions); - intit(); - } - - private void intit() { - mapView = findViewById(R.id.mapView); - tencentMap = mapView.getMap(); - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.984066, 116.307548), - 15, - 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; - BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); - MarkerOptions options = new MarkerOptions().position(new LatLng(39.984066, 116.307548)); - options.icon(custom); - mMarker = tencentMap.addMarker(options); - mMarker.setCollisions(MarkerCollisionItem.POI); - break; - case R.id.menu_close_collisionsmap: - mMarkerAdded = false; - mMarker.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(); - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java deleted file mode 100644 index d45c5ef..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerDragActivity.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.TextView; -import android.widget.Toast; - -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; - -public class MarkerDragActivity extends MarkerActivity implements TencentMap.OnMarkerDragListener{ - private TextView textView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - marker.setInfoWindowEnable(false); - aSwitch.setVisibility(View.GONE); - - textView = findViewById(R.id.tv_info); - textView.setText("长按标记开始拖动"); - textView.setVisibility(View.VISIBLE); - - marker.setDraggable(true); - tencentMap.setOnMarkerDragListener(this); - } - - @Override - public void onMarkerDragStart(Marker marker) { - Log.e("marker:","drag"); - Toast.makeText(this, "拖拽开始", Toast.LENGTH_SHORT).show(); - } - - @Override - public void onMarkerDrag(Marker marker) { - - } - - @Override - public void onMarkerDragEnd(Marker marker) { - Toast.makeText(this, "拖拽结束", Toast.LENGTH_SHORT).show(); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java deleted file mode 100644 index efc419e..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerInfoWindowActivity.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.LinearLayout; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.annotation.Nullable; - -import com.tencent.map.vector.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class MarkerInfoWindowActivity extends AbsMapActivity { - - - private static final int TYPE_BITMAP = 0; - private static final int TYPE_VIEW = 1; - - private static final int STYLE_NO_FRAME = 1; - private static final int STYLE_FRAME = 2; - - private Marker mMarker; - private Marker mAnotherMarker; - private TencentMap mTencentMap; - private int mInfoWindowAdapterStyle; - private int mInfoWindowType = TYPE_BITMAP; - private LinearLayout mCustomInfoWindowView; - - /** - * 自定义信息窗 - */ - private TencentMap.InfoWindowAdapter mInfoWindowAdapter = new TencentMap.InfoWindowAdapter() { - - TextView tvTitle; - - //返回View为信息窗自定义样式,返回null时为默认信息窗样式 - @Override - public View getInfoWindow(final Marker marker) { - if (mInfoWindowAdapterStyle == 1 && marker.equals(mMarker)) { - return createCustomInfoView(marker); - } - return null; - } - - //返回View为信息窗内容自定义样式,返回null时为默认信息窗样式 - @Override - public View getInfoContents(Marker marker) { - if (mInfoWindowAdapterStyle == 2 && marker.equals(mMarker)) { - return createCustomInfoView(marker); - } - return null; - } - - private View createCustomInfoView(Marker marker) { - mCustomInfoWindowView = (LinearLayout) View.inflate( - getApplicationContext(), R.layout.custom_infowindow, null); - tvTitle = mCustomInfoWindowView.findViewById(R.id.tv_title); - //设置自定义信息窗的内容 - tvTitle.setText("我是自定义信息窗口:"); - tvTitle.append("\n" + marker.getTitle()); - tvTitle.append("\n" + marker.getSnippet()); - return mCustomInfoWindowView; - } - }; - private boolean mMultEnable; - - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { - super.onCreate(savedInstanceState, pTencentMap); - mTencentMap = pTencentMap; - mMarker = createMarker(); - pTencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { - @Override - public boolean onMarkerClick(Marker marker) { - invalidateOptionsMenu(); - return false; - } - }); - pTencentMap.setOnInfoWindowClickListener(new TencentMap.OnInfoWindowClickListener() { - @Override - public void onInfoWindowClick(Marker marker) { - Toast.makeText(getApplicationContext(), "信息窗被点击", Toast.LENGTH_SHORT).show(); - } - - @Override - public void onInfoWindowClickLocation(int i, int i1, int i2, int i3) { - Toast.makeText(getApplicationContext(), - "尺寸:" + i + "x" + i1 + " 位置:" + i2 + "," + i3, Toast.LENGTH_SHORT).show(); - } - }); - } - - private Marker createMarker() { - if (mTencentMap == null) { - return null; - } - if (mMarker != null) { - mMarker.remove(); - mMarker = null; - } - LatLng position = new LatLng(39.908710, 116.397499); - MarkerOptions options = new MarkerOptions(position); - options.infoWindowEnable(true);//默认为true - options.title("天安门")//标注的InfoWindow的标题 - .snippet("地址: 北京市东城区东长安街")//标注的InfoWindow的内容 - .anchor(0.5f, 1) - .viewInfoWindow(mInfoWindowType == TYPE_VIEW) - .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 - mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(position, 15)); - return mTencentMap.addMarker(options); - } - - private Marker createMultMarker() { - if (mTencentMap == null) { - return null; - } - if (mAnotherMarker != null) { - mAnotherMarker.remove(); - mAnotherMarker = null; - } - LatLng position = new LatLng(39.902500,116.397750); - MarkerOptions options = new MarkerOptions(position); - options.infoWindowEnable(true);//默认为true - options.title("毛主席纪念堂")//标注的InfoWindow的标题 - .snippet("地址: 北京市东城区前门东大街11号")//标注的InfoWindow的内容 - .anchor(0.5f, 1) - .viewInfoWindow(mInfoWindowType == TYPE_VIEW) - .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker));//设置自定义Marker图标 - return mTencentMap.addMarker(options); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.infowindow, menu); - return super.onCreateOptionsMenu(menu); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - String typeName = null; - if (mInfoWindowType == TYPE_VIEW) { - typeName = "View类型"; - } else if (mInfoWindowType == TYPE_BITMAP) { - typeName = "Bitmap类型"; - } - if (typeName != null) { - menu.findItem(R.id.menu_type).setTitle(typeName) - .setVisible(!mMarker.isInfoWindowShown()); - } - menu.findItem(R.id.menu_mult).setTitle(mMultEnable ? "开启多窗口" : "关闭多窗口") - .setVisible(!mMarker.isInfoWindowShown()); - menu.findItem(R.id.menu_add).setVisible(!mMarker.isInfoWindowShown()); - menu.findItem(R.id.menu_play).setVisible(mMarker.isInfoWindowShown()); - menu.findItem(R.id.menu_delete).setVisible(mMarker.isInfoWindowShown()); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_mult_enable: - mMultEnable = true; - initMarkers(); - hideInfoWindow(); - break; - case R.id.menu_mult_close: - mMultEnable = false; - if (mAnotherMarker != null) { - mAnotherMarker.remove(); - mAnotherMarker = null; - } - - hideInfoWindow(); - break; - case R.id.menu_type_bitmap: - mInfoWindowType = TYPE_BITMAP; - initMarkers(); - hideInfoWindow(); - break; - case R.id.menu_type_view: - mInfoWindowType = TYPE_VIEW; - initMarkers(); - hideInfoWindow(); - break; - case R.id.menu_add_infowindow_default: - showInfoWindow(); - break; - case R.id.menu_add_infowindow_custom_1: - mInfoWindowAdapterStyle = STYLE_NO_FRAME; - mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); - showInfoWindow(); - break; - case R.id.menu_add_infowindow_custom_2: - mInfoWindowAdapterStyle = STYLE_FRAME; - mTencentMap.setInfoWindowAdapter(mInfoWindowAdapter); - showInfoWindow(); - break; - case R.id.menu_play: - animationPlay(); - break; - case R.id.menu_delete: - hideInfoWindow(); - break; - } - - mTencentMap.enableMultipleInfowindow(mMultEnable); - return super.onOptionsItemSelected(item); - } - - private void initMarkers() { - mMarker = createMarker(); - if (mMultEnable) { - mAnotherMarker = createMultMarker(); - } - } - - private void showInfoWindow() { - if (mMarker != null) { - mMarker.showInfoWindow(); - } - - if (mAnotherMarker != null && mMultEnable) { - mAnotherMarker.showInfoWindow(); - } - } - - private void hideInfoWindow() { - if (mMarker != null) { - mMarker.hideInfoWindow(); - } - - if (mAnotherMarker != null && mMultEnable) { - mAnotherMarker.hideInfoWindow(); - } - mTencentMap.setInfoWindowAdapter(null); - } - - private void animationPlay() { - - if (mInfoWindowType == TYPE_VIEW) { - //TODO :动画 - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java deleted file mode 100644 index b4a17c7..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/MarkerOptionsActivity.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -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.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CircleOptions; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class MarkerOptionsActivity extends SupportMapFragmentActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - options.fastLoad(true); //设置是否快速加载 - options.icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker))); //加载图标 - options.tag(tencentMap.addCircle(new CircleOptions().center(new LatLng(39.984059, 116.305756)))); //设置标签对象 - tencentMap.addMarker(options); - } - - private LatLng latLng = new LatLng(39.984864, 116.305756); - - 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; - } - - - private MarkerOptions options = new MarkerOptions(latLng). //坐标设置 - anchor(0.5f, 0.5f). //标注的锚点 - clockwise(true). //旋转角度顺时针 - draggable(true). //标注可被拖动 - flat(true). //设置3D标注 - infoWindowEnable(true). //弹出infowindow - infoWindowAnchor(0.5f, 0.5f). //标注信息infowindow锚点 - rotation(90f). //旋转角度 - snippet("气泡infowindow内容"). //设置infowindow内容 - title("标题内容"). //infowindow标题内容 - visible(true). //标注是否可见 - zIndex(0); //堆叠顺序,越大优先级越高 -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java deleted file mode 100644 index ad6a67e..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/PetalDrawable.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.Matrix; -import android.graphics.PixelFormat; -import android.graphics.drawable.Drawable; - -import cc.winboll.studio.positions.R; - - -public class PetalDrawable extends Drawable { - - private Context mContext; - private int[] mDrawableIds; - private int imageHeight; - private int imageWidth; - private float scalRate; - - public PetalDrawable(Context context, int[] drawableIds) { - mContext = context.getApplicationContext(); - mDrawableIds = drawableIds; - Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.petal_red); - imageHeight = b.getHeight(); - imageWidth = b.getWidth(); - scalRate = (float) drawableIds.length / 10; - scalRate = scalRate < 0.8f ? 0.8f : scalRate; - imageHeight *= scalRate; - imageWidth *= scalRate; - if (mDrawableIds.length < 3) { - //两张图片,分别向两边倾斜60度 - int width = (int) ((imageHeight * 1 / 2 + imageWidth * 1.732 / 2) * 2); - int height = (int) (Math.sin(Math.PI / 3 + Math.atan(imageWidth / imageHeight)) * - Math.pow(imageWidth * imageWidth + imageHeight * imageHeight, 0.5)); - setBounds(0, 0, width, height); - } else { - setBounds(0, 0, imageHeight * 2, imageHeight * 2); - } - } - - @Override - public void draw(Canvas canvas) { - float stepAngle = 360 / mDrawableIds.length; - Matrix matrix = new Matrix(); - matrix.postScale(scalRate, scalRate); - if (mDrawableIds.length < 3 && mDrawableIds.length > 1) { - Bitmap b1 = BitmapFactory.decodeResource(mContext.getResources(), mDrawableIds[0]); - matrix.postRotate(-90, imageWidth, 0); - matrix.postTranslate(-imageWidth / 4, 0); - canvas.drawBitmap(b1, matrix, null); - Bitmap b2 = BitmapFactory.decodeResource(mContext.getResources(), mDrawableIds[1]); - matrix.reset(); - matrix.postScale(scalRate, scalRate); - matrix.postRotate(90, imageWidth, imageHeight); - matrix.postTranslate(imageWidth * 3 / 4, imageWidth / 4); - canvas.drawBitmap(b2, matrix, null); - return; - } - matrix.postTranslate(imageHeight / 2, 0); - for (int i = 0; i < mDrawableIds.length; i++) { - Bitmap b = BitmapFactory.decodeResource(mContext.getResources(), mDrawableIds[i]); - matrix.postRotate(stepAngle, imageWidth / 2 + imageHeight / 2, imageHeight); - canvas.drawBitmap(b, matrix, null); - } - } - - @Override - public int getIntrinsicWidth() { - return getBounds().width(); - } - - @Override - public int getIntrinsicHeight() { - return getBounds().height(); - } - - @Override - public void setAlpha(int i) { - - } - - @Override - public void setColorFilter(ColorFilter colorFilter) { - - } - - @Override - public int getOpacity() { - return PixelFormat.UNKNOWN; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java deleted file mode 100644 index aa0a96b..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/marker/SimpleMarkerActivity.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.tencent.map.vector.demo.marker; - -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -import androidx.annotation.Nullable; - -import com.tencent.map.vector.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.AlphaAnimation; -import com.tencent.tencentmap.mapsdk.maps.model.Animation; -import com.tencent.tencentmap.mapsdk.maps.model.AnimationListener; -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.Marker; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class SimpleMarkerActivity extends AbsMapActivity { - - private TencentMap mTencentMap; - private Marker mSimpleMarker; - private Marker mCustomMarker; - - private boolean mMarkerAdded; - @Override - protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap pTencentMap) { - super.onCreate(savedInstanceState, pTencentMap); - mTencentMap = pTencentMap; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.simple_marker, menu); - return super.onCreateOptionsMenu(menu); - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add).setVisible(!mMarkerAdded); - menu.findItem(R.id.menu_delete).setVisible(mMarkerAdded); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_add_marker_simple: - if (mSimpleMarker == null) { - LatLng position = new LatLng(40.011313,116.391907); - mSimpleMarker = mTencentMap.addMarker(new MarkerOptions(position)); - mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); - mMarkerAdded = true; - } - break; - case R.id.menu_add_marker_custom: - - if (mCustomMarker == null) { - LatLng position = new LatLng(40.011313,116.391907); - BitmapDescriptor custom = BitmapDescriptorFactory.fromResource(R.drawable.marker); - mCustomMarker = mTencentMap.addMarker(new MarkerOptions(position) - .icon(custom) - .alpha(0.7f) - .flat(true) - .clockwise(false) - .rotation(30) - ); - - Animation animation = new AlphaAnimation(0.7f, 0f); - animation.setDuration(2000); - animation.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart() { - - } - - @Override - public void onAnimationEnd() { - mCustomMarker.setAlpha(1); - } - }); - mCustomMarker.setAnimation(animation); - mCustomMarker.startAnimation(); - mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(position)); - mMarkerAdded = true; - } - break; - case R.id.menu_delete: - if (mSimpleMarker != null) { - mSimpleMarker.remove(); - mSimpleMarker = null; - } - - if (mCustomMarker != null) { - mCustomMarker.remove(); - mCustomMarker = null; - } - - mMarkerAdded = false; - break; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java deleted file mode 100644 index b73ac77..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/poi/PoiClickActivity.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.tencent.map.vector.demo.poi; - -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.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -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; - -public class PoiClickActivity extends SupportMapFragmentActivity implements TencentMap.OnMapPoiClickListener { - private Switch poiSwitch; - private Marker marker; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - poiSwitch = findViewById(R.id.switch_poi); - poiSwitch.setVisibility(View.VISIBLE); - poiSwitch.setText("Poi显示"); - tencentMap.setOnMapPoiClickListener(this); - poiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - if (b){ - tencentMap.setPoisEnabled(true); - }else{ - tencentMap.setPoisEnabled(false); - if (marker != null) - marker.remove(); - } - } - }); - } - - @Override - public void onClicked(MapPoi mapPoi) { - setMarker(mapPoi.getPosition(), mapPoi.getName()); - } - - /** - * 设置标注 - */ - private void setMarker(LatLng latLng, String name){ - - if(marker != null) - marker.remove(); - MarkerOptions options = new MarkerOptions().position(latLng); - //设置infowindow - options.title("地址:"); - options.snippet(name); - marker = tencentMap.addMarker(options); - marker.showInfoWindow(); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java deleted file mode 100644 index 479d2c5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polygon/DrawPolygonActivity.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.tencent.map.vector.demo.polygon; - -import android.os.Bundle; - -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; -import com.tencent.tencentmap.mapsdk.maps.model.Polygon; -import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; - -public class DrawPolygonActivity extends SupportMapFragmentActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - LatLng[] latLngs = { - new LatLng(39.984864, 116.305756), - new LatLng(39.983618, 116.305848), - new LatLng(39.982347, 116.305966), - new LatLng(39.982412, 116.308111), - new LatLng(39.984122, 116.308224), - new LatLng(39.984955, 116.308099), - new LatLng(39.984864, 116.305756) - }; - Polygon polygon = tencentMap.addPolygon(new PolygonOptions(). - add(latLngs). - fillColor(getResources().getColor(R.color.style)). - strokeColor(getResources().getColor(R.color.colorPrimary)). - strokeWidth(1)); - tencentMap.setOnPolygonClickListener(new TencentMap.OnPolygonClickListener() { - @Override - public void onPolygonClick(Polygon polygon, LatLng latLng) { - - } - }); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java deleted file mode 100644 index a47ccd4..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polygon/PolylonOptionsActivity.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.tencent.map.vector.demo.polygon; - -import android.os.Bundle; - -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.Polygon; -import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; - -import java.util.ArrayList; -import java.util.List; - -public class PolylonOptionsActivity extends SupportMapFragmentActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Polygon polygon = tencentMap.addPolygon(polygonOptions); - polygon.setPoints(transferArrayToList(latLngs)); //Options中设置顶点 - Polygon newPolygon = tencentMap.addPolygon(newPolygonOptions); - newPolygon.setOptions(newPolygonOptions); //重新设置Options - newPolygon.setClickable(true); //设置可点击 - newPolygon.setFillColor(0xaa324354); - newPolygon.setPoints(transferArrayToList(newLatLngs)); //设置坐标 - newPolygon.setTag(tencentMap.addMarker(new MarkerOptions().position(new LatLng(39.984866, 116.305759)).title("设置标注").draggable(true))); - - - } - - private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 - List list = new ArrayList<>(); - if (latLngs == null) - return list; - for (int i = 0; i < latLngs.length; i++) - list.add(latLngs[i]); - - return list; - - } - private LatLng[] latLngs = { - new LatLng(39.984864, 116.305756), - new LatLng(39.983618, 116.305848), - new LatLng(39.982347, 116.305966), - new LatLng(39.982412, 116.308111), - new LatLng(39.984122, 116.308224), - new LatLng(39.984955, 116.308099), - new LatLng(39.984864, 116.305756) - }; - - private LatLng[] newLatLngs = { - new LatLng(39.984864, 116.305756), - new LatLng(39.983618, 116.305848), - new LatLng(39.982347, 116.305966), - new LatLng(39.982412, 116.308111), - new LatLng(39.984122, 116.308224), - new LatLng(39.984955, 116.308099), - new LatLng(39.984864, 116.305756) - }; - - - private PolygonOptions polygonOptions = new PolygonOptions(). - add(latLngs). // 添加图形坐标点 - fillColor(0x56643313). //填充颜色 - strokeColor(0xfa349012). //描边颜色 - strokeWidth(1). //描边宽度 - visible(true). //是否可见 - zIndex(0). //堆叠顺序,越大优先级越高 - clickable(true); // 是否可点击 - - private PolygonOptions newPolygonOptions = new PolygonOptions(). - addAll(transferArrayToList(newLatLngs)); //设置批量添加顶点 -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java deleted file mode 100644 index 09544c6..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polygon/TileOverlayActivity.java +++ /dev/null @@ -1,178 +0,0 @@ -package com.tencent.map.vector.demo.polygon; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.util.Log; -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.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.MarkerCollisionItem; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; -import com.tencent.tencentmap.mapsdk.maps.model.Tile; -import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay; -import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions; -import com.tencent.tencentmap.mapsdk.maps.model.TileProvider; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -public class TileOverlayActivity extends AppCompatActivity { - private MapView mapView; - private TencentMap tencentMap; - private boolean mMarkerAdded; - private TileOverlay mTileOverlay; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_tile_overlay); - initView(); - } - - private void initView() { - mapView = findViewById(R.id.mapView); - tencentMap = mapView.getMap(); - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.917505, 116.397657), - 15, - 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; - if (mTileOverlay == null) { - mTileOverlay = tencentMap.addTileOverlay( - new TileOverlayOptions(). - tileProvider(new LocalTileProvider())); - } - - break; - case R.id.menu_close_collisionsmap: - mMarkerAdded = false; - if (mTileOverlay != null) { - mTileOverlay.clearTileCache(); - mTileOverlay.remove(); - mTileOverlay = null; - } - break; - } - - supportInvalidateOptionsMenu(); - return super.onOptionsItemSelected(item); - } - - class LocalTileProvider implements TileProvider { - - @Override - public Tile getTile(int x, int y, int zoom) { - LatLng latLng = new LatLng(39.917505, 116.397657); - int iZ = 16; - double n = Math.pow(2, iZ); - int iX = (int) (((latLng.getLongitude() + 180) / 360) * n); - int iY = (int) ((1 - (Math.log(Math.tan(Math.toRadians(latLng.getLatitude())) + - (1 / Math.cos(Math.toRadians(latLng.getLatitude())))) / Math.PI)) / 2 * n); - if (iX == x && iY == y && iZ == zoom) { - Log.e("tile", "zoom:" + zoom + " x:" + x + " y:" + y); - return new Tile(256, 256, tileData()); - } - return TileProvider.NO_TILE; - } - - byte[] tileData() { - InputStream is = null; - ByteArrayOutputStream baos = null; - try { - is = getApplicationContext().getAssets().open("gugong.jpg"); - baos = new ByteArrayOutputStream(); - byte[] byteBuffer = new byte[1024]; - int count = 0; - while ((count = is.read(byteBuffer)) != -1) { - baos.write(byteBuffer, 0, count); - } - return baos.toByteArray(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (baos != null) { - try { - baos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - } - - @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(); - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java deleted file mode 100644 index 1783595..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polyline/DrawLineActivity.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.tencent.map.vector.demo.polyline; - -import android.graphics.Color; -import android.os.Bundle; -import android.view.Menu; -import android.view.MenuItem; - -import androidx.annotation.Nullable; - -import com.tencent.map.vector.demo.AbsMapActivity; -import cc.winboll.studio.positions.R; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.TencentMap; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -public class DrawLineActivity extends AbsMapActivity { - private int typeSimple = 0; - private int typeImage = 1; - private int typeColor = 2; - private int typeArrow = 3; - private int typeGradient = 4; - - private TencentMap mTencentMap; - private boolean mHasAdded; - private boolean mHasEnableText; - private Polyline polyline; - private PolylineOptions.Text mPolylineText; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState, TencentMap tencentMap) { - super.onCreate(savedInstanceState, tencentMap); - mTencentMap = tencentMap; - tencentMap.moveCamera(CameraUpdateFactory.zoomTo(15)); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.polyline, menu); - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_add).setVisible(!mHasAdded); - menu.findItem(R.id.menu_text).setTitle(mHasEnableText ? "关闭路名" : "开启路名").setVisible(mHasAdded); - menu.findItem(R.id.menu_delete).setVisible(mHasAdded); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_add_line_simple: - mTencentMap.clear(); - polyline = mTencentMap.addPolyline(setLineStyle(typeSimple)); - mHasAdded = true; - break; - - case R.id.menu_add_line_dash: - mTencentMap.clear(); - polyline = mTencentMap.addPolyline(setLineStyle(typeImage)); - mHasAdded = true; - break; - case R.id.menu_add_line_segment: - mTencentMap.clear(); - polyline = mTencentMap.addPolyline(setLineStyle(typeColor)); - int[] color = {0, 1, 2, 3, 4}; - int[] index = {0, 1, 2, 3, 4, 5}; - polyline.setColors(color, index); - mHasAdded = true; - break; - case R.id.menu_add_line_texture: - mTencentMap.clear(); - polyline = mTencentMap.addPolyline(setLineStyle((typeArrow))); - mHasAdded = true; - break; - case R.id.menu_add_line_gradient: - mTencentMap.clear(); - polyline = mTencentMap.addPolyline(setLineStyle((typeGradient))); - int[] indexes = {0, 1, 2, 3, 4}; -// 设置每段索引之间的颜色,这个颜色同样支持纹理颜色,即 PolylineOptions.Colors 中定义的 [0, 10] 值 - int[] colors = { - 0xff00ff00, // 线上点 [0, 1] 之间为绿色 - 0xffffff00, // 线上点 [1, 2] 之间为黄色 - 0xffff0000, // 线上点 [2, 3] 之间为红色 - 0xff131313, // 线上点 [3, 4] 之间为黄色 - 0xff1033f6 // 线上点 [4, 最后一个点] 之间为绿色 - }; - polyline.setColors(colors, indexes); - mHasAdded = true; - break; - case R.id.menu_text: - mHasEnableText = !mHasEnableText; - if (mHasEnableText) { - if (mPolylineText == null) { - mPolylineText = generateText(); - //设置显示优先级,可选项有HIGH或NORMAL - mPolylineText.setPriority(PolylineOptions.TextPriority.HIGH); - //设置字体大小 - mPolylineText.setTextSize(10); - //设置填充颜色 - mPolylineText.setStrokeColor(Color.WHITE); - //设置文字颜色 - mPolylineText.setTextColor(Color.BLACK); - } - - polyline.setText(mPolylineText); - } else { - polyline.setText(null); - } - - break; - - case R.id.menu_delete: - if (polyline != null) { - polyline.remove(); - polyline = null; - mHasAdded = false; - mHasEnableText = false; - - } - break; - } - return super.onOptionsItemSelected(item); - } - - private PolylineOptions setLineStyle(int type) { - PolylineOptions polylineOptions = new PolylineOptions().addAll(getLatlons()).lineCap(true); - switch (type) { - case 0: - //设置折线颜色、宽度 - polylineOptions - .color(0xff00ff00) - .width(5f); - break; - case 1: - List list = new ArrayList<>(); - list.add(35); - list.add(20); - polylineOptions - .lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE) - .width(10) - .pattern(list); - break; - case 2: - //线路颜色值纹理图片里的颜色索引 - polylineOptions - .colorType(PolylineOptions.ColorType.LINE_COLOR_TEXTURE) - .color(PolylineOptions.Colors.GREEN) - .colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")); - break; - case 3: - polylineOptions - .arrow(true) - .arrowSpacing(30) - .arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")); - break; - case 4: - polylineOptions - .gradient(true) - .lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE) - .width(20); - break; - - } - return polylineOptions; - } - - private PolylineOptions.Text generateText() { - List segmentTexts = new ArrayList<>(); - //参数分别表示坐标路径数组起点index,终点index,动态路名文字 - segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); - segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); - segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); - return new PolylineOptions.Text.Builder(segmentTexts).build(); - } - - private List getLatlons() { - List latLngs = new ArrayList(); - latLngs.add(new LatLng(39.984864, 116.305756)); - latLngs.add(new LatLng(39.983618, 116.305848)); - latLngs.add(new LatLng(39.982347, 116.305966)); - latLngs.add(new LatLng(39.982412, 116.308111)); - latLngs.add(new LatLng(39.984122, 116.308224)); - latLngs.add(new LatLng(39.984955, 116.308099)); - return latLngs; - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java deleted file mode 100644 index 1fda4de..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polyline/LineTextActivity.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.tencent.map.vector.demo.polyline; - -import android.graphics.Color; -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.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -public class LineTextActivity extends SupportMapFragmentActivity { - private Polyline polyline; - private static List mPoints = new ArrayList<>(); - private Switch switch_style; - private Switch switch_off; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - initView(); - tencentMap.moveCamera(CameraUpdateFactory.zoomTo(16)); - switch_style.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - if (polyline == null) { - return; - } - - PolylineOptions.Text text = polyline.getText(); - removeText(); - if (checked) { - //设置显示优先级,可选项有HIGH或NORMAL - text.setPriority(PolylineOptions.TextPriority.HIGH); - //设置字体大小 - text.setTextSize(10); - //设置填充颜色 - text.setStrokeColor(Color.WHITE); - //设置文字颜色 - text.setTextColor(Color.BLACK); - } else { - //设置显示优先级,可选项有HIGH或NORMAL - text.setPriority(PolylineOptions.TextPriority.NORMAL); - //设置字体大小 - text.setTextSize(8); - //设置填充颜色 - text.setStrokeColor(Color.WHITE); - //设置文字颜色 - text.setTextColor(Color.GRAY); - - } - - polyline.setText(text); - } - }); - - switch_off.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - if (checked) { - polyline = createLineWithText(); - } else { - removeText(); - polyline.remove(); - polyline = null; - } - } - }); - } - - - private void initView() { - //文字 - switch_style = (Switch) findViewById(R.id.switch_style); - switch_style.setVisibility(View.VISIBLE); - switch_off = (Switch) findViewById(R.id.switch_off); - switch_off.setVisibility(View.VISIBLE); - } - - public Polyline addLine() { - Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(mPoints).color(0x22ff0000)); - - return polyline; - } - - - //生成坐标点路径 - private List generateLatLngs() { - if (mPoints.size() != 0) - mPoints = new ArrayList<>(); - //苏州街 - mPoints.add(new LatLng(39.982382, 116.305883)); - //北四环西路辅路 - mPoints.add(new LatLng(39.984914, 116.305690)); - //彩和坊路 - mPoints.add(new LatLng(39.985045, 116.308136)); - mPoints.add(new LatLng(39.983570, 116.308088)); - mPoints.add(new LatLng(39.980063, 116.308297)); - return mPoints; - } - - private PolylineOptions.Text generateText() { - List segmentTexts = new ArrayList<>(); - //参数分别表示坐标路径数组起点index,终点index,动态路名文字 - segmentTexts.add(new PolylineOptions.SegmentText(0, 1, "苏州街")); - segmentTexts.add(new PolylineOptions.SegmentText(1, 2, "北四环西路辅路")); - segmentTexts.add(new PolylineOptions.SegmentText(2, 4, "彩和坊路")); - - return new PolylineOptions.Text.Builder(segmentTexts).build(); - } - - - private Polyline createLineWithText() { - Polyline polyline = tencentMap.addPolyline(new PolylineOptions().addAll(generateLatLngs()).text(generateText())); - PolylineOptions.Text text = polyline.getText(); - return polyline; - } - - - private void removeText() { - polyline.setText(null); - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java deleted file mode 100644 index 678ce1d..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polyline/MutablePolylineActivity.java +++ /dev/null @@ -1,291 +0,0 @@ -package com.tencent.map.vector.demo.polyline; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.view.Menu; -import android.view.MenuItem; -import android.view.SubMenu; - -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.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -import androidx.annotation.NonNull; - -/** - * @version v1.0 - * @since 2020/6/11 - */ -public class MutablePolylineActivity extends SupportMapFragmentActivity { - private boolean mIsAdd; - private Polyline mPolyline; - - private final static Object[][] sData = { - {"更新1"}, - {"更新2"}, - {"重置"}, - {"删除"}, - }; - - private List mAppendPoints = new ArrayList<>(); - private int mAppendIndex; - - private Handler sHandler = new Handler(Looper.getMainLooper()) { - @Override - public void handleMessage(@NonNull Message msg) { - super.handleMessage(msg); - - if (msg.what == 1 && mPolyline != null && mAppendIndex < mAppendPoints.size()) { - mPolyline.appendPoint(mAppendPoints.get(mAppendIndex)); - mAppendIndex++; - - sendEmptyMessageDelayed(1, 300); - } - } - }; - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_polyline_items, menu); - - MenuItem actionMenu = menu.findItem(R.id.menu_actions); - SubMenu actionSubMenu = actionMenu.getSubMenu(); - - for (int i = 0; i < sData.length; i++) { - Object[] indoor = sData[i]; - actionSubMenu.add(0, i, 0, String.valueOf(indoor[0])); - } - return true; - } - - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - menu.findItem(R.id.menu_actions).setVisible(mIsAdd); - return super.onPrepareOptionsMenu(menu); - } - - @Override - public boolean onOptionsItemSelected(@NonNull MenuItem item) { - - int itemId = item.getItemId(); - - if (mPolyline != null && itemId >= 0 && itemId < sData.length) { - if (itemId == 3) { - mPolyline.remove(); - mIsAdd = false; - mAppendIndex = 0; - invalidateOptionsMenu(); - } else if (itemId == 2) { - mPolyline.setPoints(getPoints(itemId)); - } else { - mPolyline.appendPoints(getPoints(itemId)); - } - return true; - } - - List pattern = new ArrayList<>(); - pattern.add(35); - pattern.add(20); - - PolylineOptions options = new PolylineOptions() - .addAll(getCreatePoints()) - .width(15); - - switch (item.getItemId()) { - case R.id.menu_add: - if (mIsAdd) { - break; - } - mIsAdd = true; - mPolyline = tencentMap.addPolyline(options); - break; - case R.id.menu_add_anim: - if (mIsAdd) { - break; - } - mIsAdd = true; - - mPolyline = tencentMap.addPolyline(options); - - sHandler.sendEmptyMessage(1); - break; - - } - invalidateOptionsMenu(); - return super.onOptionsItemSelected(item); - } - - private static List getCreatePoints() { - List listPoints = new ArrayList<>(); - addLine(listPoints); - return listPoints; - } - - private static List getPoints(int itemId) { - List listPoints = new ArrayList(); - if (itemId == 0) { - addLine1(listPoints); - } else if (itemId == 1) { - addLine2(listPoints); - } else if (itemId == 2) { - addLine(listPoints); - } - - return listPoints; - } - - private static void addLine(List listPoints) { - listPoints.add(new LatLng(39.981787, 116.306649)); - listPoints.add(new LatLng(39.982021, 116.306739)); - listPoints.add(new LatLng(39.982351, 116.306883)); - listPoints.add(new LatLng(39.98233, 116.306047)); - listPoints.add(new LatLng(39.982324, 116.305867)); - listPoints.add(new LatLng(39.981918, 116.305885)); - listPoints.add(new LatLng(39.981298, 116.305921)); - listPoints.add(new LatLng(39.981091, 116.305939)); - listPoints.add(new LatLng(39.980506, 116.305975)); - listPoints.add(new LatLng(39.980148, 116.306002)); - listPoints.add(new LatLng(39.980121, 116.306002)); - listPoints.add(new LatLng(39.979708, 116.306038)); - listPoints.add(new LatLng(39.979205, 116.306074)); - listPoints.add(new LatLng(39.979205, 116.306074)); - listPoints.add(new LatLng(39.978813, 116.306101)); - listPoints.add(new LatLng(39.978015, 116.306182)); - listPoints.add(new LatLng(39.977299, 116.306227)); - listPoints.add(new LatLng(39.976996, 116.306245)); - listPoints.add(new LatLng(39.976913, 116.306245)); - listPoints.add(new LatLng(39.97597, 116.306308)); - listPoints.add(new LatLng(39.97575, 116.306326)); - listPoints.add(new LatLng(39.97564, 116.306335)); - listPoints.add(new LatLng(39.975178, 116.306371)); - listPoints.add(new LatLng(39.975185, 116.306514)); - listPoints.add(new LatLng(39.97564, 116.306272)); - listPoints.add(new LatLng(39.975633, 116.306272)); - listPoints.add(new LatLng(39.975715, 116.307997)); - listPoints.add(new LatLng(39.975819, 116.311545)); - listPoints.add(new LatLng(39.975936, 116.314878)); - listPoints.add(new LatLng(39.975998, 116.317528)); - listPoints.add(new LatLng(39.976025, 116.318785)); - listPoints.add(new LatLng(39.976108, 116.321714)); - listPoints.add(new LatLng(39.976259, 116.326843)); - listPoints.add(new LatLng(39.976328, 116.328622)); - listPoints.add(new LatLng(39.976397, 116.330356)); - listPoints.add(new LatLng(39.9765, 116.333967)); - listPoints.add(new LatLng(39.976459, 116.341019)); - listPoints.add(new LatLng(39.976473, 116.341674)); - listPoints.add(new LatLng(39.976473, 116.341944)); - listPoints.add(new LatLng(39.976473, 116.342546)); - listPoints.add(new LatLng(39.976479, 116.345295)); - listPoints.add(new LatLng(39.976197, 116.353829)); - listPoints.add(new LatLng(39.976459, 116.369926)); - listPoints.add(new LatLng(39.97672, 116.381353)); - } - - private static void addLine2(List listPoints) { - listPoints.add(new LatLng(39.91254, 116.41786)); - listPoints.add(new LatLng(39.911258, 116.417905)); - listPoints.add(new LatLng(39.910459, 116.417923)); - listPoints.add(new LatLng(39.908557, 116.418049)); - listPoints.add(new LatLng(39.908337, 116.418058)); - listPoints.add(new LatLng(39.90824, 116.418067)); - listPoints.add(new LatLng(39.90669, 116.418148)); - listPoints.add(new LatLng(39.904795, 116.418283)); - listPoints.add(new LatLng(39.903416, 116.418265)); - listPoints.add(new LatLng(39.901218, 116.418408)); - listPoints.add(new LatLng(39.900805, 116.418417)); - listPoints.add(new LatLng(39.900805, 116.418426)); - listPoints.add(new LatLng(39.901335, 116.417968)); - listPoints.add(new LatLng(39.901342, 116.417968)); - listPoints.add(new LatLng(39.901342, 116.418004)); - listPoints.add(new LatLng(39.901197, 116.418193)); - listPoints.add(new LatLng(39.901204, 116.418426)); - listPoints.add(new LatLng(39.901218, 116.418552)); - listPoints.add(new LatLng(39.901087, 116.418624)); - listPoints.add(new LatLng(39.901053, 116.41884)); - listPoints.add(new LatLng(39.901004, 116.419028)); - listPoints.add(new LatLng(39.900922, 116.419388)); - listPoints.add(new LatLng(39.900839, 116.419774)); - listPoints.add(new LatLng(39.900749, 116.420043)); - listPoints.add(new LatLng(39.900722, 116.420178)); - listPoints.add(new LatLng(39.900667, 116.42034)); - listPoints.add(new LatLng(39.900619, 116.420519)); - listPoints.add(new LatLng(39.900557, 116.420744)); - listPoints.add(new LatLng(39.900515, 116.420915)); - listPoints.add(new LatLng(39.900488, 116.421067)); - listPoints.add(new LatLng(39.900467, 116.421274)); - listPoints.add(new LatLng(39.900467, 116.421301)); - listPoints.add(new LatLng(39.900467, 116.421301)); - listPoints.add(new LatLng(39.900674, 116.428856)); - listPoints.add(new LatLng(39.900681, 116.429287)); - listPoints.add(new LatLng(39.900674, 116.429287)); - listPoints.add(new LatLng(39.900694, 116.429745)); - listPoints.add(new LatLng(39.900736, 116.43173)); - listPoints.add(new LatLng(39.900729, 116.433132)); - listPoints.add(new LatLng(39.900729, 116.433267)); - listPoints.add(new LatLng(39.900743, 116.433545)); - } - - private static void addLine1(List listPoints) { - listPoints.add(new LatLng(39.976748, 116.382314)); - listPoints.add(new LatLng(39.976851, 116.388045)); - listPoints.add(new LatLng(39.976892, 116.393597)); - listPoints.add(new LatLng(39.976906, 116.394199)); - listPoints.add(new LatLng(39.976906, 116.394298)); - listPoints.add(new LatLng(39.976996, 116.405949)); - listPoints.add(new LatLng(39.977016, 116.407692)); - listPoints.add(new LatLng(39.97701, 116.417564)); - listPoints.add(new LatLng(39.97701, 116.417564)); - listPoints.add(new LatLng(39.977127, 116.417591)); - listPoints.add(new LatLng(39.977127, 116.417582)); - listPoints.add(new LatLng(39.969017, 116.417932)); - listPoints.add(new LatLng(39.968549, 116.417977)); - listPoints.add(new LatLng(39.9666, 116.418094)); - listPoints.add(new LatLng(39.965099, 116.418193)); - listPoints.add(new LatLng(39.963957, 116.418256)); - listPoints.add(new LatLng(39.961533, 116.418301)); - listPoints.add(new LatLng(39.959343, 116.418301)); - listPoints.add(new LatLng(39.95422, 116.418732)); - listPoints.add(new LatLng(39.952375, 116.418858)); - listPoints.add(new LatLng(39.952106, 116.418876)); - listPoints.add(new LatLng(39.95192, 116.418849)); - listPoints.add(new LatLng(39.951693, 116.418696)); - listPoints.add(new LatLng(39.951528, 116.418525)); - listPoints.add(new LatLng(39.951383, 116.41822)); - listPoints.add(new LatLng(39.95128, 116.417941)); - listPoints.add(new LatLng(39.951239, 116.417609)); - listPoints.add(new LatLng(39.951218, 116.417312)); - listPoints.add(new LatLng(39.951218, 116.417088)); - listPoints.add(new LatLng(39.951197, 116.416899)); - listPoints.add(new LatLng(39.951115, 116.416675)); - listPoints.add(new LatLng(39.950984, 116.416513)); - listPoints.add(new LatLng(39.950839, 116.416378)); - listPoints.add(new LatLng(39.950639, 116.41627)); - listPoints.add(new LatLng(39.950426, 116.416217)); - listPoints.add(new LatLng(39.950095, 116.416243)); - listPoints.add(new LatLng(39.948835, 116.416486)); - listPoints.add(new LatLng(39.948697, 116.416486)); - listPoints.add(new LatLng(39.945557, 116.416648)); - listPoints.add(new LatLng(39.941686, 116.416791)); - listPoints.add(new LatLng(39.941005, 116.4168)); - listPoints.add(new LatLng(39.938442, 116.416944)); - listPoints.add(new LatLng(39.936045, 116.417016)); - listPoints.add(new LatLng(39.933662, 116.417142)); - listPoints.add(new LatLng(39.929247, 116.417295)); - listPoints.add(new LatLng(39.927683, 116.417393)); - listPoints.add(new LatLng(39.926553, 116.417438)); - listPoints.add(new LatLng(39.924583, 116.417492)); - listPoints.add(new LatLng(39.924369, 116.417492)); - listPoints.add(new LatLng(39.921779, 116.417573)); - listPoints.add(new LatLng(39.919044, 116.417654)); - listPoints.add(new LatLng(39.917404, 116.417708)); - listPoints.add(new LatLng(39.917287, 116.417717)); - listPoints.add(new LatLng(39.916233, 116.417825)); - listPoints.add(new LatLng(39.913904, 116.417807)); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java deleted file mode 100644 index 8e953e5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/polyline/PolylineOptionsActivity.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.tencent.map.vector.demo.polyline; - -import android.os.Bundle; - -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.ArrayList; -import java.util.List; - -public class PolylineOptionsActivity extends SupportMapFragmentActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Polyline polyline = tencentMap.addPolyline(polylineOptions); - Polyline newPolyline = tencentMap.addPolyline(newPolylineOptions); - polyline.pattern(patternLine(patterns)); //设置虚线样式 - } - - private int[] patterns = {10, 15, 20}; - private List patternLine(int [] patterns){ - List patternLine = new ArrayList<>(); - if (patterns == null) - return patternLine; - for (int i = 0; i < patterns.length; i++) - patternLine.add(patterns[i]); - return patternLine; - } - - - private List transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换 - List list = new ArrayList<>(); - if (latLngs == null) - return list; - for (int i = 0; i < latLngs.length; i++) - list.add(latLngs[i]); - - return list; - - } - - private LatLng[] latLngs = { - new LatLng(39.984864, 116.305756), - new LatLng(39.983618, 116.305848), - new LatLng(39.982347, 116.305966), - new LatLng(39.982412, 116.308111), - new LatLng(39.984122, 116.308224), - new LatLng(39.984955, 116.308099), - new LatLng(39.984864, 116.305756) - }; - - private LatLng[] newLatLngs = { - new LatLng(39.984864, 116.305756), - new LatLng(39.983618, 116.305848), - new LatLng(39.982347, 116.305966), - new LatLng(39.982412, 116.308111), - new LatLng(39.984122, 116.308224), - new LatLng(39.984955, 116.308099), - new LatLng(39.984864, 116.305756) - }; - private PolylineOptions polylineOptions = new PolylineOptions(). - addAll(transferArrayToList(latLngs)). //添加顶点 - alpha(0.5f). //设置透明度 - arrow(true). //导航用 接口 - arrowSpacing(110). // 设置方向箭头间距 - arrowTexture(BitmapDescriptorFactory.fromAsset("color_arrow_texture.png")). // 设置箭头纹理 - borderColor(0xaa323456). //设置描边颜色 - borderWidth(1f). //设置描边宽度 - clickable(true). //可点击 - color(PolylineOptions.Colors.LIGHT_BLUE). //线的颜色 - colorTexture(BitmapDescriptorFactory.fromAsset("color_texture.png")). //颜色纹理 - lineCap(true). //路线是否显示半圆端点 - lineType(PolylineOptions.LineType.LINE_TYPE_MULTICOLORLINE). //设置线的类型 - visible(true). //设置折线可见性 - width(10f). //设置线的宽度 - zIndex(0); //堆叠顺序,越大优先级越高 - - - private PolylineOptions newPolylineOptions = new PolylineOptions().add(newLatLngs). - lineType(PolylineOptions.LineType.LINE_TYPE_DOTTEDLINE). - visible(true). - pattern(patternLine(patterns)). - zIndex(1); -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java deleted file mode 100644 index 6adef05..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/CoordianteTransferActivity.java +++ /dev/null @@ -1,101 +0,0 @@ -//package com.tencent.map.vector.demo.search; -// -//import android.content.Context; -//import android.os.Bundle; -//import android.widget.EditText; -//import android.widget.Spinner; -//import android.widget.Toast; -// -//import cc.winboll.studio.positions.R; -//import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -//import com.tencent.lbssearch.TencentSearch; -//import com.tencent.lbssearch.httpresponse.BaseObject; -//import com.tencent.lbssearch.httpresponse.HttpResponseListener; -//import com.tencent.lbssearch.object.param.TranslateParam; -//import com.tencent.lbssearch.object.result.TranslateResultObject; -//import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -// -//public class CoordianteTransferActivity extends SupportMapFragmentActivity { -// -// private EditText etCoordinate; -// private Spinner spCoordinate; -// @Override -// protected void onCreate(Bundle savedInstanceState) { -// super.onCreate(savedInstanceState); -// initView(); -// } -// -// private void initView(){ -// etCoordinate = (EditText) findViewById(R.id.et_search_poi); -// spCoordinate -// } -// /** -// * 由字符串获取坐标 -// * @param context -// * @param str -// * @return -// */ -// public static LatLng str2Coordinate(Context context, String str) { -// if (!str.contains(",")) { -// Toast.makeText(context, "经纬度用\",\"分割", Toast.LENGTH_SHORT).show(); -// return null; -// } -// String[] strs = str.split(","); -// double lat = 0; -// double lng = 0; -// try { -// lat = Double.parseDouble(strs[0]); -// lng = Double.parseDouble(strs[1]); -// } catch (NumberFormatException e) { -// Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show(); -// return null; -// } -// return new LatLng(lat, lng); -// } -// -// private static final String[] coorTypes = { -// TranslateParam.CoordType.GPS.name(), -// TranslateParam.CoordType.SOGOU.name(), -// TranslateParam.CoordType.BAIDU.name(), -// TranslateParam.CoordType.MAPBAR.name(), -// TranslateParam.CoordType.STANDARD.name(), -// TranslateParam.CoordType.SOGOUMERCATOR.name() -// }; -// -// /** -// * 坐标转换 -// */ -// protected void coorTranslate() { -// String str = etCoordinate.getText().toString().trim(); -// LatLng latLng = str2Coordinate(this, str); -// if (latLng == null) { -// return; -// } -// TencentSearch tencentSearch = new TencentSearch(this); -// TranslateParam translateParam = new TranslateParam(); -// translateParam.addLocation(latLng); -// translateParam.coordType(TranslateParam.CoordType.valueOf(coorTypes[spCoordinate.getSelectedItemPosition()])); -// tencentSearch.translate(translateParam, new HttpResponseListener() { -// -// @Override -// public void onSuccess(int arg0, BaseObject arg1) { -// // TODO Auto-generated method stub -// if (arg1 == null) { -// return; -// } -// TranslateResultObject obj = (TranslateResultObject) arg1; -// StringBuilder sb = new StringBuilder(); -// sb.append("\n latLng:" + obj.latLngs.toString()); -// printResult(sb.toString()); -// } -// -// @Override -// public void onFailure(int arg0, String arg1, Throwable arg2) { -// // TODO Auto-generated method stub -// printResult(arg1); -// } -// }); -// } -// -// -//} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java deleted file mode 100644 index 209455b..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/DistrictActivity.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.tencent.map.vector.demo.search; - -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 android.widget.TextView; -import cc.winboll.studio.positions.R; -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.DistrictChildrenParam; -import com.tencent.lbssearch.object.result.DistrictResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import java.util.ArrayList; -import java.util.List; - -public class DistrictActivity extends SupportMapFragmentActivity { - private Spinner spProvince; - private Spinner spCity; - private Spinner spDistrict; - private TextView tvResult; - private List latLngs = new ArrayList<>(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - initView(); - initSpinner(); - } - - protected void initView() { - spProvince = (Spinner) findViewById(R.id.sp_province); - spCity = (Spinner) findViewById(R.id.sp_city); - spDistrict = (Spinner) findViewById(R.id.sp_district); - tvResult = (TextView) findViewById(R.id.tv_result); - spProvince.setVisibility(View.VISIBLE); - spCity.setVisibility(View.VISIBLE); - spDistrict.setVisibility(View.VISIBLE); - tvResult.setVisibility(View.VISIBLE); - } - - protected void initSpinner() { - - //初始化行政区划,像北京市等只有市和区两级的数据,可能会输出错误id - getDistrict(0, R.id.sp_province); - AdapterView.OnItemSelectedListener onItemSelectedListener = new AdapterView.OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, - int position, long id) { - // TODO Auto-generated method stub - switch (parent.getId()) { - case R.id.sp_province: - getDistrict(((List) parent.getTag()). - get(position).intValue(), R.id.sp_city); - break; - case R.id.sp_city: - getDistrict(((List) parent.getTag()). - get(position).intValue(), R.id.sp_district); - break; - case R.id.sp_district: - getDistrict(((List) parent.getTag()). - get(position).intValue(), R.id.sp_district); - tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(latLngs.get(position), 15f, 0, 0))); - default: - break; - } - } - - @Override - public void onNothingSelected(AdapterView parent) { - // TODO Auto-generated method stub - - } - }; - spProvince.setOnItemSelectedListener(onItemSelectedListener); - spCity.setOnItemSelectedListener(onItemSelectedListener); - spDistrict.setOnItemSelectedListener(onItemSelectedListener); - } - - /** - * 获取行政区划 - */ - protected void getDistrict(int pDistrict, final int spId) { - TencentSearch tencentSearch = new TencentSearch(this); - DistrictChildrenParam districtChildrenParam = new DistrictChildrenParam(); - Log.d("eqrwqeqewr", "getDistrict: " + spId); - //如果不设置id,则获取全部数据 - if (spId != R.id.sp_province && spId == R.id.sp_city) { - districtChildrenParam.id(pDistrict); - } - if (spId != R.id.sp_province && spId != R.id.sp_city) { - districtChildrenParam.id(pDistrict); - } - - tencentSearch.getDistrictChildren(districtChildrenParam, new HttpResponseListener() { - - @Override - public void onSuccess(int arg0, BaseObject arg1) { - // TODO Auto-generated method stub - if (arg1 == null) { - return; - } - DistrictResultObject obj = (DistrictResultObject) arg1; - switch (spId) { - case R.id.sp_province: - setDistrictAdapter(spProvince, obj); - break; - case R.id.sp_city: - setDistrictAdapter(spCity, obj); - break; - case R.id.sp_district: - setDistrictAdapter(spDistrict, obj); - break; - - default: - break; - } - } - - @Override - public void onFailure(int arg0, String arg1, Throwable arg2) { - // TODO Auto-generated method stub - // printResult(arg1); - } - }); - } - - /** - * 设置行政区划的adapter - * - * @param spinner 要设置adapter的spinner - * @param obj 用于填充adapter的数据源 - */ - protected void setDistrictAdapter(Spinner spinner, final DistrictResultObject obj) { - List names = new ArrayList(); - List ids = new ArrayList(); - latLngs.clear(); - final List districtResults = obj.result.get(0); - for (final DistrictResultObject.DistrictResult result : districtResults) { - names.add(result.fullname); - ids.add(result.id); - latLngs.add(result.latLng); - Log.d("位置", "setDistrictAdapter: " + result.fullname); - - } - ArrayAdapter adapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, names); - spinner.setAdapter(adapter); - //将行政区划编码附到spinner方便后续查询 - spinner.setTag(ids); - - } - - - protected void printResult(final String result) { - runOnUiThread(new Runnable() { - - @Override - public void run() { - // TODO Auto-generated method stub - tvResult.setText(result); - } - }); - } - -} - diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java deleted file mode 100644 index a2ce36a..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/DrivingRouteActivity.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.DrivingParam; -import com.tencent.lbssearch.object.result.DrivingResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -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.PolylineOptions; - -import java.util.List; - -public class DrivingRouteActivity extends SupportMapFragmentActivity { - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(24.66493, 117.09568), - 15, - 0f, - 0f)); - //移动地图 - tencentMap.moveCamera(cameraSigma); - getDrivingRoute(); - } - - private LatLng fromPoint = new LatLng(24.66493, 117.09568); // 起点坐标 - private LatLng toPoint = new LatLng(26.8857, 120.00514); //终点坐标 - - /** - * 获取驾车路线规划 - */ - private void getDrivingRoute() { - long l = (System.currentTimeMillis() / 1000)+1000; - Log.d("时间戳", "getDrivingRoute: " + l); - DrivingParam drivingParam = new DrivingParam(fromPoint, toPoint); //创建导航参数 - drivingParam.roadType(DrivingParam.RoadType.ON_MAIN_ROAD_BELOW_BRIDGE); - drivingParam.heading(90); - drivingParam.accuracy(30); - //drivingParam.departureTime(l) - TencentSearch tencentSearch = new TencentSearch(this); - tencentSearch.getRoutePlan(drivingParam, new HttpResponseListener() { - - @Override - public void onSuccess(int i, DrivingResultObject drivingResultObject) { - if (drivingResultObject == null) { - return; - } - for (DrivingResultObject.Route route : drivingResultObject.result.routes) { - List lines = route.polyline; - tencentMap.addPolyline(new PolylineOptions().addAll(lines).color(0x22ff0000)); - tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() - .include(route.polyline).build(), 100)); - tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() - .include(lines).build(), 100)); - } - } - - @Override - public void onFailure(int i, String s, Throwable throwable) { - - } - }); - } - -} - diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java deleted file mode 100644 index 44ed8aa..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/GeoCoderActivity.java +++ /dev/null @@ -1,186 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import android.content.Context; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -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.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.httpresponse.Poi; -import com.tencent.lbssearch.object.param.Address2GeoParam; -import com.tencent.lbssearch.object.param.Geo2AddressParam; -import com.tencent.lbssearch.object.result.Address2GeoResultObject; -import com.tencent.lbssearch.object.result.Geo2AddressResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions; - -public class GeoCoderActivity extends SupportMapFragmentActivity { - - private EditText etGeocoder; - private Button btnGeocoder; - private EditText etRegeocoder; - private Button btnRegeocoder; - private TextView tvResult; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - initView(); - } - - - private void initView(){ - etGeocoder = (EditText) findViewById(R.id.et_geocoder); - btnGeocoder = (Button) findViewById(R.id.btn_geocoder); - etRegeocoder = (EditText) findViewById(R.id.et_regeocoder); - btnRegeocoder = (Button) findViewById(R.id.btn_regeocoder); - etGeocoder.setVisibility(View.VISIBLE); - btnGeocoder.setVisibility(View.VISIBLE); - etRegeocoder.setVisibility(View.VISIBLE); - btnRegeocoder.setVisibility(View.VISIBLE); - tvResult = (TextView) findViewById(R.id.tv_result); - tvResult.setVisibility(View.VISIBLE); - btnGeocoder.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - geocoder(); - } - }); - - btnRegeocoder.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - reGeocoder(); - } - }); - } - /** - *地理编码 - */ - protected void geocoder() { - TencentSearch tencentSearch = new TencentSearch(this); - String address = etGeocoder.getText().toString(); - Address2GeoParam address2GeoParam = - new Address2GeoParam(address).region("北京"); - tencentSearch.address2geo(address2GeoParam, new HttpResponseListener() { - - @Override - public void onSuccess(int arg0, BaseObject arg1) { - // TODO Auto-generated method stub - if (arg1 == null) { - return; - } - Address2GeoResultObject obj = (Address2GeoResultObject)arg1; - StringBuilder sb = new StringBuilder(); - sb.append("地址解析"); - if (obj.result.latLng != null) { - sb.append("\n坐标:" + obj.result.latLng.toString()); - } else { - sb.append("\n无坐标"); - } - printResult(sb.toString()); - tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.result.latLng,15f, 0, 0))); - tencentMap.addMarker(new MarkerOptions() - .position(obj.result.latLng)); - } - - @Override - public void onFailure(int arg0, String arg1, Throwable arg2) { - // TODO Auto-generated method stub - printResult(arg1); - } - }); - } - - /** - * 逆地理编码 - */ - protected void reGeocoder() { - String str = etRegeocoder.getText().toString().trim(); - LatLng latLng = str2Coordinate(this, str); - if (latLng == null) { - return; - } - TencentSearch tencentSearch = new TencentSearch(this); - //还可以传入其他坐标系的坐标,不过需要用coord_type()指明所用类型 - //这里设置返回周边poi列表,可以在一定程度上满足用户获取指定坐标周边poi的需求 - Geo2AddressParam geo2AddressParam = new Geo2AddressParam(latLng).getPoi(true) - .setPoiOptions(new Geo2AddressParam.PoiOptions() - .setRadius(1000).setCategorys("面包") - .setPolicy(Geo2AddressParam.PoiOptions.POLICY_O2O)); - tencentSearch.geo2address(geo2AddressParam, new HttpResponseListener() { - - @Override - public void onSuccess(int arg0, BaseObject arg1) { - // TODO Auto-generated method stub - if (arg1 == null) { - return; - } - Geo2AddressResultObject obj = (Geo2AddressResultObject)arg1; - StringBuilder sb = new StringBuilder(); - sb.append("逆地址解析"); - sb.append("\n地址:" + obj.result.address); - sb.append("\npois:"); - for (Poi poi : obj.result.pois) { - sb.append("\n\t" + poi.title); - tencentMap.addMarker(new MarkerOptions() - .position(poi.latLng) //标注的位置 - .title(poi.title) //标注的InfoWindow的标题 - .snippet(poi.address) //标注的InfoWindow的内容 - ); - } - //printResult(sb.toString()); - } - - @Override - public void onFailure(int arg0, String arg1, Throwable arg2) { - // TODO Auto-generated method stub - printResult(arg1); - } - }); - } - - - /** - * 由字符串获取坐标 - * @param context - * @param str - * @return - */ - public static LatLng str2Coordinate(Context context, String str) { - if (!str.contains(",")) { - Toast.makeText(context, "经纬度用\",\"分割", Toast.LENGTH_SHORT).show(); - return null; - } - String[] strs = str.split(","); - double lat = 0; - double lng = 0; - try { - lat = Double.parseDouble(strs[0]); - lng = Double.parseDouble(strs[1]); - } catch (NumberFormatException e) { - Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show(); - return null; - } - return new LatLng(lat, lng); - } - protected void printResult(final String result) { - runOnUiThread(new Runnable() { - - @Override - public void run() { - // TODO Auto-generated method stub - tvResult.setText(result); - } - }); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java deleted file mode 100644 index b7b2c9b..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/SearchBasicActivity.java +++ /dev/null @@ -1,305 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ListView; -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.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.BaseObject; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.SearchParam; -import com.tencent.lbssearch.object.param.SuggestionParam; -import com.tencent.lbssearch.object.result.SearchResultObject; -import com.tencent.lbssearch.object.result.SuggestionResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -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 java.lang.ref.WeakReference; -import java.util.List; - -public class SearchBasicActivity extends SupportMapFragmentActivity { - private EditText etSearch; - private Button btnSearch; - private ListView lvSuggesion; - private SuggestionAdapter suggestionAdapter; - private final int MSG_SUGGESTION = 10000; - private final MyHandler handler = new MyHandler(this); - - private static class MyHandler extends Handler { - private final WeakReference mActivity; - - public MyHandler(SearchBasicActivity activity) { - // TODO Auto-generated constructor stub - mActivity = new WeakReference<>(activity); - } - - @Override - public void handleMessage(Message msg) { - // TODO Auto-generated method stub - SearchBasicActivity activity = mActivity.get(); - if (activity != null) { - activity.handleMessage(msg); - } - } - } - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - initView(); - } - - protected void initView(){ - etSearch = (EditText) findViewById(R.id.et_search_poi); - btnSearch = (Button) findViewById(R.id.btn_search_poi); - etSearch.setVisibility(View.VISIBLE); - btnSearch.setVisibility(View.VISIBLE); - lvSuggesion = (ListView) findViewById(R.id.lv_suggestions); - - etSearch.addTextChangedListener(textWatcher); - etSearch.setOnFocusChangeListener(new View.OnFocusChangeListener() { - - @Override - public void onFocusChange(View v, boolean hasFocus) { - // TODO Auto-generated method stub - if (!etSearch.hasFocus()) { - lvSuggesion.setVisibility(View.GONE); - } - } - }); - - lvSuggesion.setOnItemClickListener(new AdapterView.OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, - int position, long id) { - // TODO Auto-generated method stub - etSearch.removeTextChangedListener(textWatcher); - CharSequence cs = - ((TextView)view.findViewById(R.id.label)).getText(); - etSearch.setText(cs); - lvSuggesion.setVisibility(View.GONE); - etSearch.addTextChangedListener(textWatcher); - } - }); - - btnSearch.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - searchPoi(); - } - }); - } - - final TextWatcher textWatcher = new TextWatcher() { - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - // TODO Auto-generated method stub - suggestion(s.toString()); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - // TODO Auto-generated method stub - - } - - @Override - public void afterTextChanged(Editable s) { - // TODO Auto-generated method stub - - } - }; - - - - /** - * poi检索 - */ - protected void searchPoi() { - TencentSearch tencentSearch = new TencentSearch(this); - String keyWord = etSearch.getText().toString().trim(); - //城市搜索 - SearchParam.Region region = new SearchParam.Region("北京").//设置搜索城市 - autoExtend(false);//设置搜索范围不扩大 - //圆形范围搜索 - LatLng latLng1 = new LatLng(39.984154, 116.307490); - SearchParam.Nearby nearBy = new SearchParam.Nearby(latLng1, 1000); - //矩形搜索,这里的范围是故宫 - LatLng latLng2 = new LatLng(39.913127, 116.392164); - LatLng latLng3 = new LatLng(39.923034, 116.402078); - SearchParam.Rectangle rectangle = new SearchParam.Rectangle(latLng2, latLng3); - - //filter()方法可以设置过滤类别, - //search接口还提供了排序方式、返回条目数、返回页码具体用法见文档, - //同时也可以参考官网的webservice对应接口的说明 - SearchParam searchParam = new SearchParam(keyWord, region);//.pageIndex(0).pageSize(20).filter("大学,中学"); - tencentSearch.search(searchParam, new HttpResponseListener() { - - @Override - public void onFailure(int arg0, String arg2, - Throwable arg3) { - Toast.makeText(getApplicationContext(), arg2, Toast.LENGTH_LONG).show(); - } - - @Override - public void onSuccess(int arg0, BaseObject arg1) { - if (arg1 == null) { - return; - } - SearchResultObject obj = (SearchResultObject) arg1; - if(obj.data == null){ - return; - } - tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(obj.data.get(0).latLng,15f, 0, 0))); - for(SearchResultObject.SearchResultData data : obj.data){ - Log.v("SearchDemo","title:"+data.title + ";" + data.address); - tencentMap.addMarker(new MarkerOptions() - .position(data.latLng) //标注的位置 - .title(data.title) //标注的InfoWindow的标题 - .snippet(data.address) //标注的InfoWindow的内容 - ); - - } - } - }); - } - - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_SUGGESTION: - showAutoComplete((SuggestionResultObject)msg.obj); - break; - - default: - break; - } - } - - /** - * 显示完整ListView - * @param obj - */ - protected void showAutoComplete(SuggestionResultObject obj) { - if (obj.data.size() == 0) { - lvSuggesion.setVisibility(View.GONE); - return; - } - if (suggestionAdapter == null) { - suggestionAdapter = new SuggestionAdapter(obj.data); - lvSuggesion.setAdapter(suggestionAdapter); - } else { - suggestionAdapter.setDatas(obj.data); - suggestionAdapter.notifyDataSetChanged(); - } - lvSuggesion.setVisibility(View.VISIBLE); - } - /** - * 关键字提示 - * @param keyword - */ - protected void suggestion(String keyword) { - if (keyword.trim().length() == 0) { - lvSuggesion.setVisibility(View.GONE); - return; - } - TencentSearch tencentSearch = new TencentSearch(this); - SuggestionParam suggestionParam = new SuggestionParam(keyword, "北京"); - //suggestion也提供了filter()方法和region方法 - //具体说明见文档,或者官网的webservice对应接口 - tencentSearch.suggestion(suggestionParam, new HttpResponseListener() { - - @Override - public void onSuccess(int arg0, BaseObject arg1) { - if (arg1 == null || - etSearch.getText().toString().trim().length() == 0) { - lvSuggesion.setVisibility(View.GONE); - return; - } - - Message msg = new Message(); - msg.what = MSG_SUGGESTION; - msg.obj = arg1; - handler.sendMessage(msg); - } - - @Override - public void onFailure(int arg0, String arg1, Throwable arg2) { - //printResult(arg1); - } - }); - } - - class SuggestionAdapter extends BaseAdapter { - - List mSuggestionDatas; - - public SuggestionAdapter(List suggestionDatas) { - // TODO Auto-generated constructor stub - setDatas(suggestionDatas); - } - - public void setDatas(List suggestionDatas) { - mSuggestionDatas = suggestionDatas; - } - - @Override - public int getCount() { - // TODO Auto-generated method stub - return mSuggestionDatas.size(); - } - - @Override - public Object getItem(int position) { - // TODO Auto-generated method stub - return mSuggestionDatas.get(position); - } - - @Override - public long getItemId(int position) { - // TODO Auto-generated method stub - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - // TODO Auto-generated method stub - ViewHolder viewHolder; - if (convertView == null) { - convertView = View.inflate(SearchBasicActivity.this, - R.layout.suggestion_list_item, null); - viewHolder = new ViewHolder(); - viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.label); - viewHolder.tvAddress = (TextView) convertView.findViewById(R.id.desc); - convertView.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.tvTitle.setText(mSuggestionDatas.get(position).title); - viewHolder.tvAddress.setText(mSuggestionDatas.get(position).address); - return convertView; - } - - private class ViewHolder{ - TextView tvTitle; - TextView tvAddress; - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java deleted file mode 100644 index c9eddc1..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/TransitRouteActivity.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.TransitParam; -import com.tencent.lbssearch.object.result.TransitResultObject; -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; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - -import java.util.List; - -public class TransitRouteActivity extends SupportMapFragmentActivity { - private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 - private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - //移动地图 - tencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(40.080287, 116.244949), - 12, - 0f, - 0f))); - getTransitRoute(); - tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() { - @Override - public void onMapClick(LatLng latLng) { - Log.d("TAG", "onMapClick: "+latLng); - } - }); - } - - /** - * 获取公交路径规划 - * TransitResultObject中的Segment是抽象类,要转换成具体的子类才能获取数据 - */ - private void getTransitRoute() { - TransitParam transitParam = new TransitParam(fromPoint, toPoint); - TencentSearch tencentSearch = new TencentSearch(this); - transitParam.policy(TransitParam.Policy.LEAST_WALKING, TransitParam.Preference.NO_SUBWAY); - tencentSearch.getRoutePlan(transitParam, new HttpResponseListener() { - - @Override - public void onSuccess(int i, TransitResultObject transitResultObject) { - if (transitResultObject == null) { - Log.i("TAG", "baseObject为空"); - return; - } - showTransitRoute(transitResultObject); - - } - - @Override - public void onFailure(int i, String s, Throwable throwable) { - Log.d("TransitRouteActivity", "onFailure: " + s); - } - }); - } - - private void showTransitRoute(TransitResultObject transitResultObject) { - tencentMap.clearAllOverlays(); - if (transitResultObject.result != null && transitResultObject.result.routes != null && transitResultObject.result.routes.size() > 0) { - for (int i = 0; i < transitResultObject.result.routes.size(); i++) { - TransitResultObject.Route route = transitResultObject.result.routes.get(i); - - List steps = route.steps; - for (int j = 0; j < steps.size(); j++) { - TransitResultObject.Segment segment = steps.get(j); - if (segment instanceof TransitResultObject.Transit) { - TransitResultObject.Transit transit = (TransitResultObject.Transit) segment; - tencentMap.addPolyline(new PolylineOptions().addAll(transit.lines.get(0).polyline).color(i + 1).width(20)); - - } else if (segment instanceof TransitResultObject.Walking) { - TransitResultObject.Walking walking = (TransitResultObject.Walking) segment; - tencentMap.addPolyline(new PolylineOptions().addAll(walking.polyline).color(j + 1).lineType(PolylineOptions.LineType.LINE_TYPE_IMAGEINARYLINE).width(20)); - } - - } - } - - } else { - Log.i("TAG", "路线结果为空"); - } - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java deleted file mode 100644 index 9b47eff..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/TruckingRouteActivity.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.TransitParam; -import com.tencent.lbssearch.object.param.TruckingParam; -import com.tencent.lbssearch.object.result.RoutePlanningObject; -import com.tencent.lbssearch.object.result.TransitResultObject; -import com.tencent.lbssearch.object.result.TruckingResultObject; -import cc.winboll.studio.positions.R; -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.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.PolylineOptions; - -import java.util.List; - -public class TruckingRouteActivity extends SupportMapFragmentActivity { - private LatLng fromPoint = new LatLng(40.127265, 116.208051); // 起点坐标 - private LatLng toPoint = new LatLng(40.040219, 116.273348); //终点坐标 - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(40.040219, 116.273348), - 15, - 0f, - 0f)); - //移动地图 - tencentMap.moveCamera(cameraSigma); - geTruckingRoute(); - } - - private void geTruckingRoute() { - TruckingParam truckingParam = new TruckingParam(); - truckingParam.from(fromPoint); - truckingParam.to(toPoint); - truckingParam.setMultRoute(1); - // truckingParam.setNoPolyline(1); - truckingParam.trafficSpeed(true); - TencentSearch tencentSearch = new TencentSearch(this); - tencentSearch.getRoutePlan(truckingParam, new HttpResponseListener() { - - @Override - public void onSuccess(int i, TruckingResultObject truckingResultObject) { - if (null != truckingResultObject.result && null != truckingResultObject.result.routes && truckingResultObject.result.routes.size() > 0) { - for (int j = 0; j < truckingResultObject.result.routes.size(); j++) { - TruckingResultObject.Result result = truckingResultObject.result; - TruckingResultObject.Route route = result.routes.get(j); - // List steps = route.steps; - tencentMap.addPolyline(new PolylineOptions().addAll(route.polyline).color(i + 1).width(20)); - tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() - .include(route.polyline).build(), 100)); - - } - } - } - - @Override - public void onFailure(int i, String s, Throwable throwable) { - Log.d("TruckingRouteActivity", "onFailure: " + s); - - } - }); - - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java deleted file mode 100644 index d8d0da4..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/search/WalkingRouteActivity.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.tencent.map.vector.demo.search; - -import android.os.Bundle; -import android.util.Log; - -import com.tencent.lbssearch.object.result.RoutePlanningObject; -import com.tencent.map.vector.demo.basic.SupportMapFragmentActivity; -import com.tencent.lbssearch.TencentSearch; -import com.tencent.lbssearch.httpresponse.HttpResponseListener; -import com.tencent.lbssearch.object.param.WalkingParam; -import com.tencent.lbssearch.object.result.WalkingResultObject; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; -import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; - - -public class WalkingRouteActivity extends SupportMapFragmentActivity { - - private LatLng fromPoint = new LatLng(40.040219, 116.273348); // 起点坐标 - private LatLng toPoint = new LatLng(40.048055, 116.281166); //终点坐标 - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - getWalkingRoute(); - } - - /** - * 获取步行路线规划 - */ - private void getWalkingRoute() { - WalkingParam walkingParam = new WalkingParam(); - walkingParam.from(fromPoint); - walkingParam.to(toPoint); - TencentSearch tencentSearch = new TencentSearch(getApplicationContext()); - Log.i("TAG", "checkParams:" + walkingParam.checkParams()); - tencentSearch.getRoutePlan(walkingParam, new HttpResponseListener() { - @Override - public void onSuccess(int statusCode, WalkingResultObject object) { - if (object == null) { - Log.i("TAG", "baseObject为空"); - return; - } - showWalkingRoute(object); - Log.i("TAG", "message:" + object.message); - } - - @Override - public void onFailure(int statusCode, String responseString, Throwable throwable) { - Log.i("TAG:", statusCode + " " + responseString); - } - }); - } - - private void showWalkingRoute(WalkingResultObject object) { - tencentMap.clearAllOverlays(); - if (object.result != null && object.result.routes != null && object.result.routes.size() > 0) { - for (int i = 0; i < object.result.routes.size(); i++) { - WalkingResultObject.Route result = object.result.routes.get(i); - tencentMap.addPolyline(new PolylineOptions().addAll(result.polyline).color(i + 1).width(20)); - Log.i("TAG", "distance:" + result.distance + " duration:" + result.duration - + " mode:" + result.mode + " direction:" + result.direction); - for (RoutePlanningObject.Step step : result.steps) { - Log.i("TAG", "step:" + step.road_name + " " + step.distance + " " - + step.instruction + " " + step.act_desc + " " + step.dir_desc); - } - tencentMap.moveCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder() - .include(result.polyline).build(), 100)); - } - - } else { - Log.i("TAG", "路线结果为空"); - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java deleted file mode 100644 index cfa5cce..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/smooth/SmoothMoveActivity.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.tencent.map.vector.demo.smooth; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.graphics.drawable.RoundedBitmapDrawable; -import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.ImageView; - -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.BitmapDescriptorFactory; -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.Polyline; -import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; -import com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Timer; -import java.util.TimerTask; - -import static com.tencent.tencentmap.mapsdk.vector.utils.animation.MarkerTranslateAnimator.MarkerTranslateStatusListener.AnimationStatus.AnimationComplete; - -public class SmoothMoveActivity extends AppCompatActivity implements View.OnClickListener { - private MapView mapView; - 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 TencentMap map; - private Polyline mPolyline; - private Marker mCarMarker; - private LatLng[] mCarLatLngArray; - private MarkerTranslateAnimator mAnimator; - private Polyline polyline; - private ArrayList skews; - private ArrayList roates; - private String parentPath; - private ImageView imageView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_smooth_move); - mapView = findViewById(R.id.map); - map = mapView.getMap(); - //解析路线 - init(); - Button btLin = findViewById(R.id.button_set); - Button btStart = findViewById(R.id.satrt); - Button btStop = findViewById(R.id.stop); - btLin.setOnClickListener(this); - btStart.setOnClickListener(this); - btStop.setOnClickListener(this); - } - - private void init() { - String[] linePointsStr = mLine.split(","); - mCarLatLngArray = new LatLng[linePointsStr.length / 4]; - skews = new ArrayList<>(); - roates = new ArrayList<>(); - - for (int i = 0; i < mCarLatLngArray.length; i++) { - double latitude = Double.parseDouble(linePointsStr[i * 4]); - double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]); - // float skew = Float.parseFloat(linePointsStr[i * 4 + 2]); - // float roate = Float.parseFloat(linePointsStr[i * 4 + 3]); - mCarLatLngArray[i] = new LatLng(latitude, longitude); - // skews.add(skew); - // roates.add(roate); - } - } - - @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(); - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.button_set: - if (polyline == null && mCarMarker == null) { - //添加小车路线 - polyline = map.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorPrimaryDark)); - LatLng carLatLng = mCarLatLngArray[0]; - mCarMarker = map.addMarker( - new MarkerOptions(carLatLng) - .anchor(0.5f, 0.5f) - .title("即将到达终点") - .icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.taxi))) - .flat(true) - .clockwise(false)); - //调整最佳视界 - map.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50)); - TimerTask timerTask = new TimerTask() { - @Override - public void run() { - if (polyline != null) { - snapshot(); - } - - } - }; - Timer timer = new Timer(); - timer.schedule(timerTask, 800); - } - break; - case R.id.satrt: - if (mAnimator == null) { - //创建移动动画 - mAnimator = new MarkerTranslateAnimator(mCarMarker, 100 * 1000, mCarLatLngArray, true, new MarkerTranslateAnimator.MarkerTranslateStatusListener() { - private CameraUpdate cameraSigma; - - @Override - public void onInterpolatePoint(LatLng latLng, int i, AnimationStatus animationStatus) { - //路线擦出 - polyline.setEraseable(true); - polyline.eraseTo(i, latLng); - - /* CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBoundsWithMapCenter(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), latLng, 10); - map.animateCamera(cameraUpdate);*/ - if (mCarMarker.getRotation() < 90 && mCarMarker.getRotation() > 0) { - cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - latLng, - 18, - 60, - mCarMarker.getRotation() + 180)); - } else if (mCarMarker.getRotation() >= 90 && mCarMarker.getRotation() <= 180) { - cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - latLng, - 18, - 60, - -mCarMarker.getRotation())); - } else { - cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - latLng, - 18, - 60, - -mCarMarker.getRotation())); - } - - //移动地图 - map.moveCamera(cameraSigma); - map.enableMultipleInfowindow(true); - if (i == 41) { - mCarMarker.startAnimation(); - mCarMarker.showInfoWindow(); - } - if (animationStatus == AnimationComplete) { - mCarMarker.setTitle("到达目的地"); - } - } - }); - - - //开启动画 - mAnimator.startAnimation(); - } - break; - case R.id.stop: - if (mAnimator != null && polyline != null && mCarMarker != null) { - mAnimator.endAnimation(); - //mAnimator.cancelAnimation(); - polyline.remove(); - polyline = null; - mCarMarker.remove(); - mCarMarker = null; - mAnimator = null; - } - - - break; - default: - throw new IllegalStateException("Unexpected value: " + v.getId()); - } - } - - private void snapshot() { - imageView = findViewById(R.id.iv); - - map.snapshot(new TencentMap.SnapshotReadyCallback() { - @Override - public void onSnapshotReady(Bitmap bitmap) { - RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap); - roundedBitmapDrawable.setCircular(true); - imageView.setImageDrawable(roundedBitmapDrawable); - } - }, Bitmap.Config.ARGB_8888); - } - - //设置图片 - private Bitmap getBitMap(int resourceId) { - Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - int newWidth = 100; - int newHeight = 150; - 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; - } -} \ No newline at end of file diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java deleted file mode 100644 index a485ce5..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/transaction/AnimateCameraActivity.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.tencent.map.vector.demo.transaction; - -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.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class AnimateCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { - - private Button btn; - private boolean flag; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - btn = findViewById(R.id.btn_bottom); - btn.setVisibility(View.VISIBLE); - btn.setText("以动画的方式改变地图视图"); - btn.setOnClickListener(this); - - flag = true; - } - - /** - * 改变地图视图 - * @param v - */ - @Override - public void onClick(View v) { - if(flag){ - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.977290,116.337000), //新的中心点坐标 - 19, //新的缩放级别 - 40f, //俯仰角 0~45° (垂直地图时为0) - 45f)); //偏航角 0~360° (正北方为0) - //移动地图 - tencentMap.animateCamera(cameraSigma); - flag = !flag; - }else { - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.877290,116.437000), //新的中心点坐标 - 18, //新的缩放级别 - 0f, //俯仰角 0~45° (垂直地图时为0) - 0f)); //偏航角 0~360° (正北方为0) - //移动地图 - tencentMap.animateCamera(cameraSigma); - flag = !flag; - } - - } - -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java deleted file mode 100644 index 8586b4f..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/transaction/MoveCameraActivity.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.tencent.map.vector.demo.transaction; - -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.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition; -import com.tencent.tencentmap.mapsdk.maps.model.LatLng; - -public class MoveCameraActivity extends SupportMapFragmentActivity implements View.OnClickListener { - - - private Button btn; - private boolean flag; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - btn = findViewById(R.id.btn_bottom); - btn.setVisibility(View.VISIBLE); - btn.setText("以移动的方式改变地图视图"); - btn.setOnClickListener(this); - - flag = true; - } - - /** - * 改变地图视图 - * @param v - */ - @Override - public void onClick(View v) { - if(flag){ - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.977290,116.337000), //新的中心点坐标 - 19, //新的缩放级别 - 40f, //俯仰角 0~45° (垂直地图时为0) - 45f)); //偏航角 0~360° (正北方为0) - //移动地图 - tencentMap.moveCamera(cameraSigma); - flag = !flag; - }else { - CameraUpdate cameraSigma = - CameraUpdateFactory.newCameraPosition(new CameraPosition( - new LatLng(39.877290,116.437000), //新的中心点坐标 - 18, //新的缩放级别 - 0f, //俯仰角 0~45° (垂直地图时为0) - 0f)); //偏航角 0~360° (正北方为0) - //移动地图 - tencentMap.moveCamera(cameraSigma); - flag = !flag; - } - - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java deleted file mode 100644 index 7fda144..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/transaction/RotateMapActivity.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.tencent.map.vector.demo.transaction; - -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.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; - -public class RotateMapActivity extends SupportMapFragmentActivity { - private Button btn; - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - btn = findViewById(R.id.btn_bottom); - btn.setVisibility(View.VISIBLE); - btn.setText("旋转地图"); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - CameraUpdate cameraUpdate = CameraUpdateFactory.rotateTo(90f,1.5f); - tencentMap.animateCamera(cameraUpdate); - } - }); - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java deleted file mode 100644 index 73b2e8d..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ScollMapActivity.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.tencent.map.vector.demo.transaction; - -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.CompoundButton; -import android.widget.LinearLayout; - -import cc.winboll.studio.positions.R; -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.TencentMap; - -public class ScollMapActivity extends SupportMapFragmentActivity implements View.OnClickListener { - private static final int SCROLL_BY_PX = 100; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - LinearLayout linearLayout = findViewById(R.id.ll); - linearLayout.setVisibility(View.VISIBLE); - Button scrollLeft = (Button) findViewById(R.id.scroll_left); - scrollLeft.setOnClickListener(this); - - Button scrollRight = (Button) findViewById(R.id.scroll_right); - scrollRight.setOnClickListener(this); - - Button scrollUp = (Button) findViewById(R.id.scroll_up); - scrollUp.setOnClickListener(this); - - Button scrollDown = (Button) findViewById(R.id.scroll_down); - scrollDown.setOnClickListener(this); - - /* btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - CameraUpdate cameraUpdate = CameraUpdateFactory.scrollBy(50f,50f); - tencentMap.animateCamera(cameraUpdate); - } - });*/ - } - - - // 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域 - - private void changeCamera(CameraUpdate update, TencentMap.CancelableCallback callback) { - boolean animated = ((CompoundButton) findViewById(R.id.animate)) - .isChecked(); - if (animated) { - tencentMap.animateCamera(update, 1000, callback); - } else { - tencentMap.moveCamera(update); - } - } - - @Override - public void onClick(View v) { - switch (v.getId()) { - //点击向左移动按钮响应事件,camera将向左边移动 - - case R.id.scroll_left: - changeCamera(CameraUpdateFactory.scrollBy(-SCROLL_BY_PX, 0), null); - break; - // 点击向右移动按钮响应事件,camera将向右边移动 - case R.id.scroll_right: - changeCamera(CameraUpdateFactory.scrollBy(SCROLL_BY_PX, 0), null); - break; - // 点击向上移动按钮响应事件,camera将向上边移动 - case R.id.scroll_up: - changeCamera(CameraUpdateFactory.scrollBy(0, -SCROLL_BY_PX), null); - break; - // 点击向下移动按钮响应事件,camera将向下边移动 - case R.id.scroll_down: - changeCamera(CameraUpdateFactory.scrollBy(0, SCROLL_BY_PX), null); - break; - - default: - break; - } - } -} diff --git a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java b/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java deleted file mode 100644 index 62d7059..0000000 --- a/positions/src/main/java/com/tencent/map/vector/demo/transaction/ZoomCalulateActivity.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.tencent.map.vector.demo.transaction; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Matrix; -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.tencentmap.mapsdk.maps.CameraUpdate; -import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory; -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 java.util.ArrayList; - -public class ZoomCalulateActivity extends SupportMapFragmentActivity { - - private Button btn; - private int leftpadding = 50,rightpadding =50, toppadding = 50, bottompadding=50; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - btn = findViewById(R.id.btn_bottom); - btn.setVisibility(View.VISIBLE); - btn.setText("根据点集缩放地图"); - btn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(addMarker()); - tencentMap.moveCamera(cameraUpdate); - } - }); - } - - - private CameraPosition addMarker(){ - ArrayList points = new ArrayList<>(); - points.add(new LatLng(39.984059,116.307621)); - points.add(new LatLng(39.984049,116.307631)); -// points.add(new LatLng(39.981527,116.308994)); -// points.add(new LatLng(39.984026,116.316419)); -// points.add(new LatLng(39.978501,116.311827)); - //根据markers计算缩放级别 - for(int i=0; i - diff --git a/positions/src/main/res/layout/activity_settings.xml b/positions/src/main/res/layout/activity_settings.xml index b77a699..d93e0ec 100644 --- a/positions/src/main/res/layout/activity_settings.xml +++ b/positions/src/main/res/layout/activity_settings.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - diff --git a/positions/src/main/res/values/styles.xml b/positions/src/main/res/values/styles.xml index 5f3bdbf..9ca4b5f 100644 --- a/positions/src/main/res/values/styles.xml +++ b/positions/src/main/res/values/styles.xml @@ -1,5 +1,5 @@ -