添加demo
@@ -17,6 +17,15 @@ def genVersionName(def versionName){
 | 
				
			|||||||
    return "${versionName}." + winbollBuildProps['stageCount']
 | 
					    return "${versionName}." + winbollBuildProps['stageCount']
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Properties properties = new Properties()
 | 
				
			||||||
 | 
					File localFile = project.rootProject.file('local.properties')
 | 
				
			||||||
 | 
					if (localFile.exists()) {
 | 
				
			||||||
 | 
					    InputStream inputStream = localFile.newDataInputStream()
 | 
				
			||||||
 | 
					    properties.load(inputStream)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def mapsdkkey = properties.getProperty('mapsdk.key', "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
android {
 | 
					android {
 | 
				
			||||||
    compileSdkVersion 32
 | 
					    compileSdkVersion 32
 | 
				
			||||||
    buildToolsVersion "33.0.3"
 | 
					    buildToolsVersion "33.0.3"
 | 
				
			||||||
@@ -49,9 +58,17 @@ android {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dependencies {
 | 
					dependencies {
 | 
				
			||||||
    // 卫星定位类库
 | 
					    api 'androidx.recyclerview:recyclerview:1.1.0'
 | 
				
			||||||
    api 'com.google.android.gms:play-services-maps:18.1.0'
 | 
					    api 'androidx.appcompat:appcompat:1.1.0'
 | 
				
			||||||
    api 'com.google.android.gms:play-services-location:21.0.1'
 | 
					    api 'androidx.constraintlayout:constraintlayout:1.1.3'
 | 
				
			||||||
 | 
					    api 'pub.devrel:easypermissions:2.0.1'
 | 
				
			||||||
 | 
					    // 地图
 | 
				
			||||||
 | 
					    api 'com.tencent.map:tencent-map-vector-sdk:6.2.1.250120.3f971009.140342819'
 | 
				
			||||||
 | 
					    // 基础库
 | 
				
			||||||
 | 
					    api 'com.tencent.openmap:foundation:0.5.6.9be4e02'
 | 
				
			||||||
 | 
					    api 'com.tencent.map:sdk-utilities:1.0.9'
 | 
				
			||||||
 | 
					    api 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.5.4.3'
 | 
				
			||||||
 | 
					    api 'com.google.code.gson:gson:2.8.5'
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    // 二维码使用的类库
 | 
					    // 二维码使用的类库
 | 
				
			||||||
    api 'com.google.zxing:core:3.4.1'
 | 
					    api 'com.google.zxing:core:3.4.1'
 | 
				
			||||||
@@ -63,9 +80,9 @@ dependencies {
 | 
				
			|||||||
    api 'org.jsoup:jsoup:1.13.1'
 | 
					    api 'org.jsoup:jsoup:1.13.1'
 | 
				
			||||||
    api 'com.squareup.okhttp3:okhttp:4.4.1'
 | 
					    api 'com.squareup.okhttp3:okhttp:4.4.1'
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    api 'androidx.appcompat:appcompat:1.1.0'
 | 
					    //api 'androidx.appcompat:appcompat:1.1.0'
 | 
				
			||||||
    api 'androidx.viewpager:viewpager:1.0.0'
 | 
					    api 'androidx.viewpager:viewpager:1.0.0'
 | 
				
			||||||
    api 'androidx.fragment:fragment:1.1.0'
 | 
					    api 'androidx.fragment:fragment:1.0.0'
 | 
				
			||||||
    api 'com.google.android.material:material:1.4.0'
 | 
					    api 'com.google.android.material:material:1.4.0'
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    api 'cc.winboll.studio:libapputils:9.3.2'
 | 
					    api 'cc.winboll.studio:libapputils:9.3.2'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
#Created by .winboll/winboll_app_build.gradle
 | 
					#Created by .winboll/winboll_app_build.gradle
 | 
				
			||||||
#Sat Feb 22 11:42:07 GMT 2025
 | 
					#Sun Feb 23 19:49:38 GMT 2025
 | 
				
			||||||
stageCount=0
 | 
					stageCount=0
 | 
				
			||||||
libraryProject=
 | 
					libraryProject=
 | 
				
			||||||
baseVersion=1.0
 | 
					baseVersion=1.0
 | 
				
			||||||
publishVersion=1.0.0
 | 
					publishVersion=1.0.0
 | 
				
			||||||
buildCount=54
 | 
					buildCount=60
 | 
				
			||||||
baseBetaVersion=1.0.1
 | 
					baseBetaVersion=1.0.1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,28 @@
 | 
				
			|||||||
<?xml version='1.0' encoding='utf-8'?>
 | 
					<?xml version='1.0' encoding='utf-8'?>
 | 
				
			||||||
<manifest
 | 
					<manifest
 | 
				
			||||||
    xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					    xmlns:android="http://schemas.android.com/apk/res/android"
 | 
				
			||||||
 | 
					    xmlns:tools="http://schemas.android.com/tools"
 | 
				
			||||||
    package="cc.winboll.studio.positions">
 | 
					    package="cc.winboll.studio.positions">
 | 
				
			||||||
 | 
					    <!-- 访问网络. 某些位置信息需要从网络服务器获取 -->
 | 
				
			||||||
    <!-- 只能在前台获取精确的位置信息 -->
 | 
					    <uses-permission android:name="android.permission.INTERNET" />
 | 
				
			||||||
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 | 
					        <!-- 访问WiFi状态. 需要WiFi信息用于网络定位 -->
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 | 
				
			||||||
    <!-- 只能在前台获取大概位置(基于网络) -->
 | 
					        <!-- 修改WiFi状态. 发起WiFi扫描, 需要WiFi信息用于网络定位 -->
 | 
				
			||||||
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
 | 
					    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 | 
				
			||||||
 | 
					        <!-- 访问网络状态, 检测网络的可用性. 需要网络运营商相关信息用于网络定位 -->
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
 | 
				
			||||||
 | 
					        <!-- 访问网络的变化, 需要某些信息用于网络定位 -->
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 | 
				
			||||||
 | 
					        <!-- 访问手机当前状态, 需要device id用于网络定位 -->
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.INTERNET" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
 | 
				
			||||||
 | 
					    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <application
 | 
					    <application
 | 
				
			||||||
        android:name=".App"
 | 
					        android:name=".App"
 | 
				
			||||||
@@ -16,13 +31,24 @@
 | 
				
			|||||||
        android:label="@string/app_name"
 | 
					        android:label="@string/app_name"
 | 
				
			||||||
        android:theme="@style/MyAppTheme"
 | 
					        android:theme="@style/MyAppTheme"
 | 
				
			||||||
        android:supportsRtl="true"
 | 
					        android:supportsRtl="true"
 | 
				
			||||||
        android:hardwareAccelerated="true">
 | 
					        android:hardwareAccelerated="true"
 | 
				
			||||||
 | 
					        android:usesCleartextTraffic="true"
 | 
				
			||||||
 | 
					        tools:ignore="AllowBackup,GoogleAppIndexingWarning"
 | 
				
			||||||
 | 
					        tools:targetApi="p">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <activity
 | 
					        <activity
 | 
				
			||||||
            android:name=".MainActivity"
 | 
					            android:name=".MainActivity"
 | 
				
			||||||
            android:label="@string/app_name"
 | 
					            android:label="@string/app_name"
 | 
				
			||||||
            android:exported="true">
 | 
					            android:exported="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".activities.LocationActivity"
 | 
				
			||||||
 | 
					            android:label="@string/app_name"
 | 
				
			||||||
 | 
					            android:exported="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        </activity>
 | 
					        </activity>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <activity
 | 
					        <activity
 | 
				
			||||||
@@ -30,14 +56,6 @@
 | 
				
			|||||||
            android:label="@string/app_name"
 | 
					            android:label="@string/app_name"
 | 
				
			||||||
            android:exported="true">
 | 
					            android:exported="true">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <intent-filter>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                <action android:name="android.intent.action.MAIN"/>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                <category android:name="android.intent.category.LAUNCHER"/>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            </intent-filter>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        </activity>
 | 
					        </activity>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <activity android:name="cc.winboll.studio.positions.activities.SettingsActivity"/>
 | 
					        <activity android:name="cc.winboll.studio.positions.activities.SettingsActivity"/>
 | 
				
			||||||
@@ -70,6 +88,510 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        </provider>
 | 
					        </provider>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <activity android:name="cc.winboll.studio.positions.activities.MapViewActivity"/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        <activity android:name=".demo.MainActivity">
 | 
				
			||||||
 | 
					            <intent-filter>
 | 
				
			||||||
 | 
					                <action android:name="android.intent.action.MAIN" />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <category android:name="android.intent.category.LAUNCHER" />
 | 
				
			||||||
 | 
					            </intent-filter>
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.MapViewActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_show_map"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_show_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.SetMapTypeActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_type"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_type">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.MapRenderLayerActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_show_mapRenderLayer"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_show_mapRenderLayer">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".location.LocationLayerActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_show_location"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_show_location">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_location" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".location.LocationPointActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_change_location_style"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_change_location_style">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_location" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.IndoorMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_indoor_map"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_indoor_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.OverseaMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_oversea"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_oversea">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.MapStyleDemoActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_style"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_style">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.UiSettingsActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_ui"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_ui">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".gesture.GestureSettingsActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_gesture"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_gesture">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.ZoomMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_modify_zoom"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_modify_zoom">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".camera.MapCameraCenterActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_modify_map_center"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_modify_map_center">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".camera.MapBoundActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_bound"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_bound">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".poi.PoiClickActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_click_poi"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_click_poi">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.AnimateCameraActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_animate_camera"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_animate_camera">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".camera.MapAnchorZoomActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_camera_anchor"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_camera_anchor">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_interactive" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.ScollMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_camera_translation"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_camera_translation">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.RotateMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_camera_rotation"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_camera_rotation">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.ZoomCalulateActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_camera_include_points"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_camera_include_points">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".transaction.MoveCameraActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_camera_change_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_camera_change_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".gesture.MapListenActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_click_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_click_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".gesture.MapLongClickActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_long_click_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_long_click_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_transformation" />
 | 
				
			||||||
 | 
					        </activity> <!-- 标注 -->
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.SimpleMarkerActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_simple_marker"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_simple_marker">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerCollisions"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_collisions_marker"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_collisions_marker">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerOptionsActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_marker_options"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_marker_options">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerClickActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_marker_click_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_marker_click_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerDragActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_marker_drag_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_marker_drag_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerInfoWindowActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_infowindow_click_listener"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_infowindow_click_listener">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerClusterActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_marker_cluster"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_marker_cluster">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.MarkerAnimation"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_marker_animation"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_marker_animation">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_marker" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.DrawHeatOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_heat_map"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_heat_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".polygon.TileOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_tileOverlay_map"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_tileOverlay_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".polyline.DrawLineActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_polyline"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_polyline">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".polyline.MutablePolylineActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_mutable_polyline"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_mutable_polyline">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".polygon.DrawPolygonActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_polygon"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_polygon">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".circle.DrawCircleActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_circle"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_circle">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".circle.ArcActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_arc"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_arc">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.WalkingRouteActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_walking_plan"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_walking_plan">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_route_plan" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.DrivingRouteActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_driving_plan"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_driving_plan">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_route_plan" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.TransitRouteActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_transit_plan"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_transit_plan">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_route_plan" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.TruckingRouteActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_truking_plan"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_truking_plan">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_route_plan" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.SearchBasicActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_basic_search"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_basic_search">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_search" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.GeoCoderActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_geocoder"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_geocoder">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_search" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".search.DistrictActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_district"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_district">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_search" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".polyline.LineTextActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_line_text"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_line_text">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_special" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".utils.BitMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_bitmap"
 | 
				
			||||||
 | 
					            android:enabled="false"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_bitmap">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_tools" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".utils.SnapshotActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_map_snapshot"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_map_snapshot">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_tools" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".utils.CoordinateActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_projection"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_projection">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_tools" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity android:name=".basic.SupportMapFragmentActivity" />
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.CustomRenderActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_opengl"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_opengl">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.GroundOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_overlay"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_ground_overlay">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".marker.AoiLayerActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_aoi"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_aoi">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.VectorHeatMapActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_vectorheatmap"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_vectorheatmap">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.ArcLineLayerActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_arcline"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_arcline_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.HeatMapVectorOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_3dheatmap"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_3d_heat_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.AggregationOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_AggregationOverlay"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_3d_aggregationOverlay_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.ScatterPlotOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_ScatterPlotOverlay"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_3d_scatterplotoverlay_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.TrailOverlayActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_TrailOverlay"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_3d_railoverltay_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".heatoverlay.GLModelActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_glModel"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_glModel">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					<!--        <activity-->
 | 
				
			||||||
 | 
					<!--            android:name=".basic.OfflineMapActivity"-->
 | 
				
			||||||
 | 
					<!--            android:description="@string/demo_description_offline_map"-->
 | 
				
			||||||
 | 
					<!--            android:label="@string/demo_label_offline_map">-->
 | 
				
			||||||
 | 
					<!--            <meta-data-->
 | 
				
			||||||
 | 
					<!--                android:name="@string/demo_type"-->
 | 
				
			||||||
 | 
					<!--                android:value="@string/demo_type_basic" />-->
 | 
				
			||||||
 | 
					<!--        </activity>-->
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".basic.RecyclerListActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_recycler_map"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_recycler_map">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_basic" />
 | 
				
			||||||
 | 
					        </activity>
 | 
				
			||||||
 | 
					        <activity
 | 
				
			||||||
 | 
					            android:name=".smooth.SmoothMoveActivity"
 | 
				
			||||||
 | 
					            android:description="@string/demo_description_smooth_move"
 | 
				
			||||||
 | 
					            android:label="@string/demo_label_smooth_move">
 | 
				
			||||||
 | 
					            <meta-data
 | 
				
			||||||
 | 
					                android:name="@string/demo_type"
 | 
				
			||||||
 | 
					                android:value="@string/demo_type_draw" />
 | 
				
			||||||
 | 
					        </activity> <!-- 如果您key确认无误,却依然授权没有通过,请检查您的key的白名单配置 -->
 | 
				
			||||||
 | 
					        <meta-data
 | 
				
			||||||
 | 
					            android:name="TencentMapSDK"
 | 
				
			||||||
 | 
					            android:value="您的Key" />
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
    </application>
 | 
					    </application>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</manifest>
 | 
					</manifest>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/21.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 4.3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/22.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 32 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/23.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 6.3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/24.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 33 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/25.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 19 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/26.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 6.4 KiB  | 
							
								
								
									
										50
									
								
								positions/src/main/assets/arc.dat
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					31.23037 121.4737 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					30.5702 104.06476 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					22.54286 114.05956 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					23.12908 113.26436 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					29.56471 106.55073 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					30.27415 120.15515 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					24.87966 102.83322 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					34.32932 108.70929 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					45.80216 126.5358 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					28.22778 112.93886 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					18.25248 109.51209 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					43.82663 87.61688 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					30.59276 114.30525 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					22.27534 114.16546 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					26.64702 106.63024 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					24.47951 118.08948 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					20.04422 110.19989 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					28.68202 115.85794 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					43.81602 125.32357 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					36.06623 120.38299 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					22.81673 108.3669 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					26.07421 119.29647 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					38.91369 121.61476 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					41.80563 123.43236 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					32.05838 118.79647 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					36.06138 103.83417 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					38.48644 106.23248 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					27.99492 120.69939 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					37.46353 121.44801 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					22.27073 113.57668 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					29.87386 121.55027 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					31.82057 117.22901 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					34.34127 108.93984 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					49.21163 119.76584 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					40.84149 111.75199 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					37.87059 112.55067 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					46.58758 125.10307 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					25.27361 110.29002 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					31.46751 104.6796 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					24.87389 118.67587 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					30.69186 111.28642 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					23.54972 116.37271 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					40.65781 109.84021 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					37.51348 122.12171 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					31.49099 120.31237 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					22.18684 113.54294 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					34.74725 113.62493 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					34.61812 112.45361 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					36.50204 102.104287 40.07733 116.60039 45.0
 | 
				
			||||||
 | 
					24.954708 121.48068 40.07733 116.60039 45.0
 | 
				
			||||||
							
								
								
									
										10
									
								
								positions/src/main/assets/arcDistricts.dat
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,10 @@
 | 
				
			|||||||
 | 
					39.90469 116.40717 29.56471 106.55073 30.0
 | 
				
			||||||
 | 
					39.90469 116.40717 39.53775 116.68376 30.0
 | 
				
			||||||
 | 
					39.90469 116.40717 31.23037 121.4737 30.0
 | 
				
			||||||
 | 
					39.90469 116.40717 23.12908 113.26436 30.0
 | 
				
			||||||
 | 
					39.90469 116.40717 28.22778 112.93886 30.0
 | 
				
			||||||
 | 
					29.56471 106.55073 39.90469 116.40717 60.0
 | 
				
			||||||
 | 
					18.25248 109.51209 39.90469 116.40717 60.0
 | 
				
			||||||
 | 
					31.23037 121.4737 39.90469 116.40717 60.0
 | 
				
			||||||
 | 
					23.12908 113.26436 39.90469 116.40717 60.0
 | 
				
			||||||
 | 
					39.53775 116.68376 39.90469 116.40717 60.0
 | 
				
			||||||
							
								
								
									
										25
									
								
								positions/src/main/assets/cluster_new
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					116.307621	39.984059
 | 
				
			||||||
 | 
					116.304703	39.981954
 | 
				
			||||||
 | 
					116.312256	39.984355
 | 
				
			||||||
 | 
					116.315346	39.980442
 | 
				
			||||||
 | 
					116.308994	39.981527
 | 
				
			||||||
 | 
					116.310539	39.979751
 | 
				
			||||||
 | 
					116.305776	39.977252
 | 
				
			||||||
 | 
					116.316419	39.984026
 | 
				
			||||||
 | 
					116.314874	39.976956
 | 
				
			||||||
 | 
					116.311827	39.978501
 | 
				
			||||||
 | 
					116.312814	39.980277
 | 
				
			||||||
 | 
					116.369022	39.980236
 | 
				
			||||||
 | 
					116.368486	39.980236
 | 
				
			||||||
 | 
					116.367488	39.977161
 | 
				
			||||||
 | 
					116.396713	39.915398
 | 
				
			||||||
 | 
					116.455421	39.937645
 | 
				
			||||||
 | 
					116.321182	39.896304
 | 
				
			||||||
 | 
					121.452827	31.254487
 | 
				
			||||||
 | 
					121.485443	31.225133
 | 
				
			||||||
 | 
					121.442528	31.216912
 | 
				
			||||||
 | 
					121.500893	31.251552
 | 
				
			||||||
 | 
					121.455917	31.249204
 | 
				
			||||||
 | 
					114.042892	22.546885
 | 
				
			||||||
 | 
					113.999805	22.538086
 | 
				
			||||||
 | 
					114.082031	22.538086
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/color_arrow_texture.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 781 B  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/color_texture.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 712 B  | 
							
								
								
									
										2000
									
								
								positions/src/main/assets/data2k
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										1000
									
								
								positions/src/main/assets/datab
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										9162
									
								
								positions/src/main/assets/gltf-BrainStem/BrainStem.gltf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/gltf-BrainStem/BrainStem0.bin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/groundoverlay.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 71 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								positions/src/main/assets/gugong.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 49 KiB  | 
							
								
								
									
										11671
									
								
								positions/src/main/assets/honeycomb.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										2
									
								
								positions/src/main/assets/trailData.dat
									
									
									
									
									
										Normal file
									
								
							
							
						
						@@ -25,6 +25,7 @@ import cc.winboll.studio.libapputils.app.WinBollActivityManager;
 | 
				
			|||||||
import cc.winboll.studio.libapputils.bean.APPInfo;
 | 
					import cc.winboll.studio.libapputils.bean.APPInfo;
 | 
				
			||||||
import cc.winboll.studio.libapputils.view.YesNoAlertDialog;
 | 
					import cc.winboll.studio.libapputils.view.YesNoAlertDialog;
 | 
				
			||||||
import cc.winboll.studio.positions.R;
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.activities.MapViewActivity;
 | 
				
			||||||
import cc.winboll.studio.positions.activities.SettingsActivity;
 | 
					import cc.winboll.studio.positions.activities.SettingsActivity;
 | 
				
			||||||
import cc.winboll.studio.positions.adapters.MyPagerAdapter;
 | 
					import cc.winboll.studio.positions.adapters.MyPagerAdapter;
 | 
				
			||||||
import cc.winboll.studio.positions.beans.MainServiceBean;
 | 
					import cc.winboll.studio.positions.beans.MainServiceBean;
 | 
				
			||||||
@@ -320,6 +321,10 @@ final public class MainActivity extends AppCompatActivity implements IWinBollAct
 | 
				
			|||||||
            Intent intent = new Intent(this, SettingsActivity.class);
 | 
					            Intent intent = new Intent(this, SettingsActivity.class);
 | 
				
			||||||
            startActivity(intent);
 | 
					            startActivity(intent);
 | 
				
			||||||
            //WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
 | 
					            //WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
 | 
				
			||||||
 | 
					        } else if (item.getItemId() == R.id.item_location) {
 | 
				
			||||||
 | 
					            Intent intent = new Intent(this, MapViewActivity.class);
 | 
				
			||||||
 | 
					            startActivity(intent);
 | 
				
			||||||
 | 
					            //WinBollActivityManager.getInstance(this).startWinBollActivity(this, CallActivity.class);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
//        } else 
 | 
					//        } else 
 | 
				
			||||||
//        if (item.getItemId() == R.id.item_exit) {
 | 
					//        if (item.getItemId() == R.id.item_exit) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,8 +29,8 @@ public class Main2Activity extends AppCompatActivity {
 | 
				
			|||||||
        // 设置网格参数
 | 
					        // 设置网格参数
 | 
				
			||||||
        mapView.setGridParameters(10000f, 10000f, 10f);
 | 
					        mapView.setGridParameters(10000f, 10000f, 10f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 初始化显示区域(中心点400,300,显示范围200x200)
 | 
					        // 初始化显示区域(中心点400,300,显示范围2000x200)
 | 
				
			||||||
        mapView.initViewport(5000f, 5000f, 2000f, 2000f);
 | 
					        mapView.initViewport(5000f, 5000f, 1000f, 1000f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 绘制图形
 | 
					        // 绘制图形
 | 
				
			||||||
        mapView.drawPoint(5000f, 5000f, Color.RED, 8f);
 | 
					        mapView.drawPoint(5000f, 5000f, Color.RED, 8f);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,83 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.activities;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @Author ZhanGSKen@AliYun.Com
 | 
				
			||||||
 | 
					 * @Date 2025/02/24 03:07:45
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					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.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.pm.PackageManager;
 | 
				
			||||||
 | 
					import android.os.Build;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					import androidx.annotation.RequiresApi;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class AbsActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final int PERMISSIONS_REQUEST_CODE = 0x99FF;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(@Nullable Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
 | 
				
			||||||
 | 
					            requestPermission();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @RequiresApi(api = Build.VERSION_CODES.M)
 | 
				
			||||||
 | 
					    private void requestPermission() {
 | 
				
			||||||
 | 
					        String[] permissions = onRequestPermissions();
 | 
				
			||||||
 | 
					        if (permissions != null) {
 | 
				
			||||||
 | 
					            List<String> deniedPermissions = new ArrayList<>();
 | 
				
			||||||
 | 
					            for (String permission : permissions) {
 | 
				
			||||||
 | 
					                if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
 | 
				
			||||||
 | 
					                    deniedPermissions.add(permission);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (deniedPermissions.size() > 0) {
 | 
				
			||||||
 | 
					                requestPermissions(deniedPermissions.toArray(new String[0]), PERMISSIONS_REQUEST_CODE);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected String[] onRequestPermissions() {
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.Intent;
 | 
				
			||||||
 | 
					import android.net.Uri;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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)));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					import androidx.fragment.app.FragmentManager;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,277 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MainActivity extends AbsListActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String DEMO_TYPE = "DEMO_TYPE";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static List<DemoInfo> mDemoTypes;
 | 
				
			||||||
 | 
					    private static Map<String, List<DemoInfo>> mDemoMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        getDemos();
 | 
				
			||||||
 | 
					        setupViews(getIntent().getStringExtra(DEMO_TYPE));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected String[] onRequestPermissions() {
 | 
				
			||||||
 | 
					        return new String[]{
 | 
				
			||||||
 | 
					                Manifest.permission.WRITE_EXTERNAL_STORAGE,
 | 
				
			||||||
 | 
					                Manifest.permission.READ_PHONE_STATE
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected int getLayoutId() {
 | 
				
			||||||
 | 
					        return R.layout.activity_main_demo;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void setupViews(String type) {
 | 
				
			||||||
 | 
					        RecyclerView recyclerView = findViewById(R.id.layout_recycle_container);
 | 
				
			||||||
 | 
					        if (recyclerView != null) {
 | 
				
			||||||
 | 
					            RecyclerView.LayoutManager layoutManager =
 | 
				
			||||||
 | 
					                    new LinearLayoutManager(getApplicationContext());
 | 
				
			||||||
 | 
					            recyclerView.setLayoutManager(layoutManager);
 | 
				
			||||||
 | 
					            recyclerView.addItemDecoration(new DividerItemDecoration(
 | 
				
			||||||
 | 
					                    getApplicationContext(), DividerItemDecoration.VERTICAL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DemoActivityAdapter activityAdapter = new DemoActivityAdapter(type);
 | 
				
			||||||
 | 
					            recyclerView.setAdapter(activityAdapter);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void getDemos() {
 | 
				
			||||||
 | 
					        if (mDemoMap != null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mDemoMap = new HashMap<>(16);
 | 
				
			||||||
 | 
					        mDemoTypes = new ArrayList<>(16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ActivityInfo[] activityIfs = new ActivityInfo[0];
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            activityIfs = getPackageManager().getPackageInfo(getPackageName(),
 | 
				
			||||||
 | 
					                    PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA).activities;
 | 
				
			||||||
 | 
					        } catch (PackageManager.NameNotFoundException pE) {
 | 
				
			||||||
 | 
					            pE.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (ActivityInfo activityInfo : activityIfs) {
 | 
				
			||||||
 | 
					            if (activityInfo.metaData != null) {
 | 
				
			||||||
 | 
					                String demoType = activityInfo.metaData.getString(
 | 
				
			||||||
 | 
					                        getResources().getString(R.string.demo_type));
 | 
				
			||||||
 | 
					                List<DemoInfo> items = mDemoMap.get(demoType);
 | 
				
			||||||
 | 
					                if (items == null) {
 | 
				
			||||||
 | 
					                    items = new ArrayList<>();
 | 
				
			||||||
 | 
					                    mDemoMap.put(demoType, items);
 | 
				
			||||||
 | 
					                    mDemoTypes.add(new DemoInfo(
 | 
				
			||||||
 | 
					                            MainActivity.class.getName(),
 | 
				
			||||||
 | 
					                            demoType,
 | 
				
			||||||
 | 
					                            ""));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                items.add(new DemoInfo(
 | 
				
			||||||
 | 
					                        activityInfo.name,
 | 
				
			||||||
 | 
					                        getString(activityInfo.labelRes),
 | 
				
			||||||
 | 
					                        getString(activityInfo.descriptionRes)));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static class DemoInfo {
 | 
				
			||||||
 | 
					        private String name;
 | 
				
			||||||
 | 
					        private String label;
 | 
				
			||||||
 | 
					        private String description;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public DemoInfo(String name, String label, String description) {
 | 
				
			||||||
 | 
					            this.name = name;
 | 
				
			||||||
 | 
					            this.label = label;
 | 
				
			||||||
 | 
					            this.description = description;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public String getName() {
 | 
				
			||||||
 | 
					            return name;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public String getLabel() {
 | 
				
			||||||
 | 
					            return label;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public String getDescription() {
 | 
				
			||||||
 | 
					            return description;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public boolean equals(@Nullable Object obj) {
 | 
				
			||||||
 | 
					            if (this == obj) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!(obj instanceof DemoInfo)) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            DemoInfo info = (DemoInfo) obj;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (!Objects.equals(this.name, info.name)) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!Objects.equals(this.label, info.label)) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (!Objects.equals(this.description, info.description)) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int hashCode() {
 | 
				
			||||||
 | 
					            int hash = name != null ? name.hashCode() : 0;
 | 
				
			||||||
 | 
					            hash = 31 * hash + (label != null ? label.hashCode() : 0);
 | 
				
			||||||
 | 
					            hash = 31 * hash + (description != null ? description.hashCode() : 0);
 | 
				
			||||||
 | 
					            return hash;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private class DemoActivityAdapter extends ListAdapter<DemoInfo, DemoInfoHolder> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int mType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        DemoActivityAdapter(String type) {
 | 
				
			||||||
 | 
					            super(new DiffUtil.ItemCallback<DemoInfo>() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public boolean areItemsTheSame(@NonNull DemoInfo oldItem, @NonNull DemoInfo newItem) {
 | 
				
			||||||
 | 
					                    return oldItem.name.equals(newItem.name);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public boolean areContentsTheSame(@NonNull DemoInfo oldItem, @NonNull DemoInfo newItem) {
 | 
				
			||||||
 | 
					                    return oldItem.equals(newItem);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            if (TextUtils.isEmpty(type)) {
 | 
				
			||||||
 | 
					                mType = DemoInfoHolder.ITEM_TYPE_GROUP;
 | 
				
			||||||
 | 
					                submitList(mDemoTypes);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                mType = DemoInfoHolder.ITEM_TYPE_ENTRY;
 | 
				
			||||||
 | 
					                submitList(mDemoMap.get(type));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @NonNull
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public DemoInfoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
				
			||||||
 | 
					            return new DemoInfoHolder(MainActivity.this, parent, viewType);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onBindViewHolder(@NonNull DemoInfoHolder holder, int position) {
 | 
				
			||||||
 | 
					            holder.bindView(getItem(position));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getItemViewType(int position) {
 | 
				
			||||||
 | 
					            return mType;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static class DemoInfoHolder<T extends DemoInfo> extends RecyclerView.ViewHolder {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private static final int ITEM_TYPE_GROUP = 0;
 | 
				
			||||||
 | 
					        private static final int ITEM_TYPE_ENTRY = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private int mViewType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private TextView mTitle;
 | 
				
			||||||
 | 
					        private TextView mSubTitle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private Context mContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        DemoInfoHolder(Context context, ViewGroup pParent, int pViewType) {
 | 
				
			||||||
 | 
					            super(LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_2, pParent, false));
 | 
				
			||||||
 | 
					            mViewType = pViewType;
 | 
				
			||||||
 | 
					            mContext = context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mTitle = itemView.findViewById(android.R.id.text1);
 | 
				
			||||||
 | 
					            mTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mSubTitle = itemView.findViewById(android.R.id.text2);
 | 
				
			||||||
 | 
					            mSubTitle.setTextColor(Color.GRAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void bindView(T pItem) {
 | 
				
			||||||
 | 
					            if (mViewType == ITEM_TYPE_GROUP) {
 | 
				
			||||||
 | 
					                setupItemGroup(pItem);
 | 
				
			||||||
 | 
					            } else if (mViewType == ITEM_TYPE_ENTRY) {
 | 
				
			||||||
 | 
					                setupItemEntry(pItem);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void setupItemGroup(final T pItem) {
 | 
				
			||||||
 | 
					            mTitle.setText(pItem.getLabel());
 | 
				
			||||||
 | 
					            mSubTitle.setVisibility(View.GONE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            itemView.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void onClick(View v) {
 | 
				
			||||||
 | 
					                    try {
 | 
				
			||||||
 | 
					                        Intent intent = new Intent(mContext, Class.forName(pItem.getName()));
 | 
				
			||||||
 | 
					                        intent.putExtra(DEMO_TYPE, pItem.getLabel());
 | 
				
			||||||
 | 
					                        mContext.startActivity(intent);
 | 
				
			||||||
 | 
					                    } catch (ClassNotFoundException pE) {
 | 
				
			||||||
 | 
					                        pE.printStackTrace();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        private void setupItemEntry(final T pItem) {
 | 
				
			||||||
 | 
					            mTitle.setText(pItem.getLabel());
 | 
				
			||||||
 | 
					            mSubTitle.setText(pItem.getDescription());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            itemView.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void onClick(View v) {
 | 
				
			||||||
 | 
					                    try {
 | 
				
			||||||
 | 
					                        Intent intent = new Intent(mContext, Class.forName(pItem.getName()));
 | 
				
			||||||
 | 
					                        mContext.startActivity(intent);
 | 
				
			||||||
 | 
					                    } catch (ClassNotFoundException pE) {
 | 
				
			||||||
 | 
					                        pE.printStackTrace();
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,544 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.basic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.app.Activity;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.graphics.Bitmap;
 | 
				
			||||||
 | 
					import android.graphics.BitmapFactory;
 | 
				
			||||||
 | 
					import android.graphics.Canvas;
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.graphics.ColorFilter;
 | 
				
			||||||
 | 
					import android.graphics.Paint;
 | 
				
			||||||
 | 
					import android.graphics.Rect;
 | 
				
			||||||
 | 
					import android.graphics.drawable.Drawable;
 | 
				
			||||||
 | 
					import android.text.TextPaint;
 | 
				
			||||||
 | 
					import android.util.AttributeSet;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					import android.util.TypedValue;
 | 
				
			||||||
 | 
					import android.view.Gravity;
 | 
				
			||||||
 | 
					import android.view.MotionEvent;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
 | 
					import android.widget.LinearLayout;
 | 
				
			||||||
 | 
					import android.widget.ScrollView;
 | 
				
			||||||
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class IndoorFloorView extends ScrollView {
 | 
				
			||||||
 | 
					    public static final String TAG = IndoorFloorView.class
 | 
				
			||||||
 | 
					            .getSimpleName();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Context context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private LinearLayout views;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int itemHeight = 0;
 | 
				
			||||||
 | 
					    private List<String> items;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int scrollDirection = -1;
 | 
				
			||||||
 | 
					    private static final int SCROLL_DIRECTION_UP = 0;
 | 
				
			||||||
 | 
					    private static final int SCROLL_DIRECTION_DOWN = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int viewWidth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Bitmap selectBitmap = null;
 | 
				
			||||||
 | 
					    //背景色
 | 
				
			||||||
 | 
					    private int backGroundColor = Color.parseColor("#00000000");
 | 
				
			||||||
 | 
					    //边框色
 | 
				
			||||||
 | 
					    private int strokeColor = Color.parseColor("#00000000");
 | 
				
			||||||
 | 
					    private int strokeWidth = 0; // 边框宽度
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int offset = 1; // 偏移量在最前面和最后面补全
 | 
				
			||||||
 | 
					    private int displayItemCount; // 每页显示的数
 | 
				
			||||||
 | 
					    int selectedIndex = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private int initialY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Runnable scrollerTask;
 | 
				
			||||||
 | 
					    private int newCheck = 50;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IndoorFloorView(Context context) {
 | 
				
			||||||
 | 
					        super(context);
 | 
				
			||||||
 | 
					        init(context);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IndoorFloorView(Context context, AttributeSet attrs) {
 | 
				
			||||||
 | 
					        super(context, attrs);
 | 
				
			||||||
 | 
					        init(context);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public IndoorFloorView(Context context, AttributeSet attrs,
 | 
				
			||||||
 | 
					                           int defStyle) {
 | 
				
			||||||
 | 
					        super(context, attrs, defStyle);
 | 
				
			||||||
 | 
					        init(context);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getOffset() {
 | 
				
			||||||
 | 
					        return offset;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 修改偏移量,即当第一个显示在中间是上面有几个空白<br>
 | 
				
			||||||
 | 
					     * 也会影响整体显示,如设置1,上下各偏移1,总共显3个;设置2总共显示5个;
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param offset
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setOffset(int offset) {
 | 
				
			||||||
 | 
					        this.offset = offset;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init(Context context) {
 | 
				
			||||||
 | 
					        this.context = context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.setVerticalScrollBarEnabled(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        selectBitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.radius);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        views = new LinearLayout(context);
 | 
				
			||||||
 | 
					        views.setOrientation(LinearLayout.VERTICAL);
 | 
				
			||||||
 | 
					        this.addView(views);
 | 
				
			||||||
 | 
					        scrollerTask = new Runnable() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            public void run() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                int newY = getScrollY();
 | 
				
			||||||
 | 
					                if (initialY - newY == 0) { // stopped
 | 
				
			||||||
 | 
					                    final int remainder = initialY % itemHeight;
 | 
				
			||||||
 | 
					                    final int divided = initialY / itemHeight;
 | 
				
			||||||
 | 
					                    if (remainder == 0) {
 | 
				
			||||||
 | 
					                        selectedIndex = divided + offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        onSeletedCallBack();
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        if (remainder > itemHeight / 2) {
 | 
				
			||||||
 | 
					                          IndoorFloorView.this.post(new Runnable() {
 | 
				
			||||||
 | 
					                                @Override
 | 
				
			||||||
 | 
					                                public void run() {
 | 
				
			||||||
 | 
					                                 IndoorFloorView.this.smoothScrollTo(
 | 
				
			||||||
 | 
					                                            0, initialY - remainder
 | 
				
			||||||
 | 
					                                                    + itemHeight);
 | 
				
			||||||
 | 
					                                    selectedIndex = divided + offset + 1;
 | 
				
			||||||
 | 
					                                    onSeletedCallBack();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            IndoorFloorView.this.post(new Runnable() {
 | 
				
			||||||
 | 
					                                @Override
 | 
				
			||||||
 | 
					                                public void run() {
 | 
				
			||||||
 | 
					                                    IndoorFloorView.this.smoothScrollTo(
 | 
				
			||||||
 | 
					                                            0, initialY - remainder);
 | 
				
			||||||
 | 
					                                    selectedIndex = divided + offset;
 | 
				
			||||||
 | 
					                                    onSeletedCallBack();
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            });
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } else {
 | 
				
			||||||
 | 
					                    initialY = getScrollY();
 | 
				
			||||||
 | 
					                    IndoorFloorView.this.postDelayed(scrollerTask,
 | 
				
			||||||
 | 
					                            newCheck);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void startScrollerTask() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        initialY = getScrollY();
 | 
				
			||||||
 | 
					        this.postDelayed(scrollerTask, newCheck);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void initData() {
 | 
				
			||||||
 | 
					        if(items==null||items.size()==0){
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        views.removeAllViews();
 | 
				
			||||||
 | 
					        displayItemCount = offset * 2 + 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i=items.size()-1;i>=0;i--) {
 | 
				
			||||||
 | 
					            views.addView(createView(items.get(i)));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        refreshItemView(0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private TextView createView(String item) {
 | 
				
			||||||
 | 
					        TextView tv = new TextView(context);
 | 
				
			||||||
 | 
					        tv.setLayoutParams(new LayoutParams(
 | 
				
			||||||
 | 
					                ViewGroup.LayoutParams.MATCH_PARENT,
 | 
				
			||||||
 | 
					                ViewGroup.LayoutParams.WRAP_CONTENT));
 | 
				
			||||||
 | 
					        tv.setSingleLine(true);
 | 
				
			||||||
 | 
					        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
 | 
				
			||||||
 | 
					        tv.setText(item);
 | 
				
			||||||
 | 
					        tv.setGravity(Gravity.CENTER);
 | 
				
			||||||
 | 
					        TextPaint tp = tv.getPaint();
 | 
				
			||||||
 | 
					        tp.setFakeBoldText(true);
 | 
				
			||||||
 | 
					        int padding_h = dip2px(context, 8);
 | 
				
			||||||
 | 
					        int padding_v = dip2px(context, 6);
 | 
				
			||||||
 | 
					        tv.setPadding(padding_h, padding_v, padding_h, padding_v);
 | 
				
			||||||
 | 
					        if (0 == itemHeight) {
 | 
				
			||||||
 | 
					            itemHeight = getViewMeasuredHeight(tv);
 | 
				
			||||||
 | 
					            views.setLayoutParams(new LayoutParams(
 | 
				
			||||||
 | 
					                    ViewGroup.LayoutParams.WRAP_CONTENT, itemHeight
 | 
				
			||||||
 | 
					                    * displayItemCount));
 | 
				
			||||||
 | 
					            this.setLayoutParams(new LinearLayout.LayoutParams(
 | 
				
			||||||
 | 
					                    LayoutParams.WRAP_CONTENT, itemHeight * displayItemCount));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return tv;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void refreshItemView(int y) {
 | 
				
			||||||
 | 
					        int position = y / itemHeight + offset;
 | 
				
			||||||
 | 
					        int remainder = y % itemHeight;
 | 
				
			||||||
 | 
					        int divided = y / itemHeight;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (remainder == 0) {
 | 
				
			||||||
 | 
					            position = divided + offset;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if (remainder > itemHeight / 2) {
 | 
				
			||||||
 | 
					                position = divided + offset + 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int childSize = views.getChildCount();
 | 
				
			||||||
 | 
					        for (int i = 0; i < childSize; i++) {
 | 
				
			||||||
 | 
					            TextView itemView = (TextView) views.getChildAt(i);
 | 
				
			||||||
 | 
					            if (null == itemView) {
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (position == i) {
 | 
				
			||||||
 | 
					                itemView.setTextColor(Color.parseColor("#0079ff"));
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                itemView.setTextColor(Color.parseColor("#ccebfc"));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<String> getItems() {
 | 
				
			||||||
 | 
					        return items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 设置显示的内容
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param list
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setItems(List<String> list) {
 | 
				
			||||||
 | 
					        if (null == items) {
 | 
				
			||||||
 | 
					            items = new ArrayList<String>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        items.clear();
 | 
				
			||||||
 | 
					        items.addAll(list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 前面和后面补
 | 
				
			||||||
 | 
					        for (int i = 0; i < offset; i++) {
 | 
				
			||||||
 | 
					            items.add(0, "");
 | 
				
			||||||
 | 
					            items.add("");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        initData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 设置显示的内容
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param strs
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setItems(String[] strs) {
 | 
				
			||||||
 | 
					        if (null == items) {
 | 
				
			||||||
 | 
					            items = new ArrayList<String>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        items.clear();
 | 
				
			||||||
 | 
					        for (int i = 0; i < strs.length; i++)
 | 
				
			||||||
 | 
					            items.add(strs[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // 前面和后面补
 | 
				
			||||||
 | 
					        for (int i = 0; i < offset; i++) {
 | 
				
			||||||
 | 
					            items.add(0, "");
 | 
				
			||||||
 | 
					            items.add("");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        initData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setBackgroundColor(int color) {
 | 
				
			||||||
 | 
					        this.backGroundColor = color;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStrokeColor(int color) {
 | 
				
			||||||
 | 
					        this.strokeColor = color;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setStrokeWidth(int width) {
 | 
				
			||||||
 | 
					        this.strokeWidth = width;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 设置选中状图片
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param bitmap
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public void setIndoorSelectBitmap(Bitmap bitmap) {
 | 
				
			||||||
 | 
					        this.selectBitmap = bitmap;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void destroy() {
 | 
				
			||||||
 | 
					        if (selectBitmap != null && !selectBitmap.isRecycled()) {
 | 
				
			||||||
 | 
					            selectBitmap.recycle();
 | 
				
			||||||
 | 
					            selectBitmap = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setBackgroundDrawable(Drawable background) {
 | 
				
			||||||
 | 
					        if (viewWidth == 0) {
 | 
				
			||||||
 | 
					            viewWidth = ((Activity) context).getWindowManager()
 | 
				
			||||||
 | 
					                    .getDefaultDisplay().getWidth();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        background = new Drawable() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void draw(Canvas canvas) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    drawBg(canvas);
 | 
				
			||||||
 | 
					                    drawCenterLine(canvas);
 | 
				
			||||||
 | 
					                    drawStroke(canvas);
 | 
				
			||||||
 | 
					                } catch (Throwable e) {
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            private void drawBg(Canvas canvas) {
 | 
				
			||||||
 | 
					                canvas.drawColor(backGroundColor);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /**
 | 
				
			||||||
 | 
					             * @param canvas
 | 
				
			||||||
 | 
					             */
 | 
				
			||||||
 | 
					            private void drawCenterLine(Canvas canvas) {
 | 
				
			||||||
 | 
					                final Paint paint = new Paint();
 | 
				
			||||||
 | 
					                Rect src = new Rect();// 图片 >>原矩
 | 
				
			||||||
 | 
					                Rect dst = new Rect();// 屏幕 >>目标矩形
 | 
				
			||||||
 | 
					                //133 122
 | 
				
			||||||
 | 
					                Log.d("IndoorFloorView", "drawCenterLine: "+selectBitmap.getWidth()+"\n"+selectBitmap.getHeight());
 | 
				
			||||||
 | 
					                src.left = 0;
 | 
				
			||||||
 | 
					                src.top = 0;
 | 
				
			||||||
 | 
					                src.right = 0 + selectBitmap.getWidth();
 | 
				
			||||||
 | 
					                src.bottom = 0 + selectBitmap.getHeight();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                dst.left = 0;
 | 
				
			||||||
 | 
					                dst.top = obtainSelectedAreaBorder()[0];
 | 
				
			||||||
 | 
					                dst.right = 0 + viewWidth;
 | 
				
			||||||
 | 
					                dst.bottom = obtainSelectedAreaBorder()[1];
 | 
				
			||||||
 | 
					                canvas.drawBitmap(selectBitmap, src, dst, paint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /**
 | 
				
			||||||
 | 
					             * @param canvas
 | 
				
			||||||
 | 
					             */
 | 
				
			||||||
 | 
					            private void drawStroke(Canvas canvas) {
 | 
				
			||||||
 | 
					                final Paint mPaint = new Paint();
 | 
				
			||||||
 | 
					                Rect rect = canvas.getClipBounds();
 | 
				
			||||||
 | 
					                mPaint.setColor(strokeColor);
 | 
				
			||||||
 | 
					                mPaint.setStyle(Paint.Style.STROKE);
 | 
				
			||||||
 | 
					                mPaint.setStrokeWidth(strokeWidth);
 | 
				
			||||||
 | 
					                canvas.drawRect(rect, mPaint);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void setAlpha(int alpha) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void setColorFilter(ColorFilter cf) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public int getOpacity() {
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        super.setBackgroundDrawable(background);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取选中区域的边
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private int[] obtainSelectedAreaBorder() {
 | 
				
			||||||
 | 
					        int[] selectedAreaBorder = null;
 | 
				
			||||||
 | 
					        if (null == selectedAreaBorder) {
 | 
				
			||||||
 | 
					            selectedAreaBorder = new int[2];
 | 
				
			||||||
 | 
					            selectedAreaBorder[0] = itemHeight * offset;
 | 
				
			||||||
 | 
					            selectedAreaBorder[1] = itemHeight * (offset + 1);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return selectedAreaBorder;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
 | 
				
			||||||
 | 
					        super.onSizeChanged(w, h, oldw, oldh);
 | 
				
			||||||
 | 
					        viewWidth = w;
 | 
				
			||||||
 | 
					        setBackgroundDrawable(null);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
 | 
				
			||||||
 | 
					        super.onScrollChanged(l, t, oldl, oldt);
 | 
				
			||||||
 | 
					        refreshItemView(t);
 | 
				
			||||||
 | 
					        if (t > oldt) {
 | 
				
			||||||
 | 
					            scrollDirection = SCROLL_DIRECTION_DOWN;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            scrollDirection = SCROLL_DIRECTION_UP;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 选中回调
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void onSeletedCallBack() {
 | 
				
			||||||
 | 
					        if (null != onIndoorFloorSwtichListener) {
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                onIndoorFloorSwtichListener.onSelected(getSeletedIndex());
 | 
				
			||||||
 | 
					            } catch (Throwable e) {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSeletion(String selectValue) {
 | 
				
			||||||
 | 
					        if(items==null||items.size()==0){
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        int position = items.indexOf(selectValue);
 | 
				
			||||||
 | 
					        final int p = items.size()-offset-1-position;
 | 
				
			||||||
 | 
					        selectedIndex = p + offset;
 | 
				
			||||||
 | 
					        this.post(new Runnable() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void run() {
 | 
				
			||||||
 | 
					                IndoorFloorView.this.smoothScrollTo(0, p * itemHeight);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSeletedItem() {
 | 
				
			||||||
 | 
					        return items.get(selectedIndex);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getSeletedIndex() {
 | 
				
			||||||
 | 
					        if(items==null||items.size()==0){
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        int result = items.size()-1-selectedIndex - offset;
 | 
				
			||||||
 | 
					        return Math.min(items.size() - 2 * offset, Math.max(0, result));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void fling(int velocityY) {
 | 
				
			||||||
 | 
					        super.fling(velocityY / 3);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onTouchEvent(MotionEvent ev) {
 | 
				
			||||||
 | 
					        if (ev.getAction() == MotionEvent.ACTION_UP) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            startScrollerTask();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return super.onTouchEvent(ev);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private OnIndoorFloorListener onIndoorFloorSwtichListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public OnIndoorFloorListener getOnIndoorFloorListener() {
 | 
				
			||||||
 | 
					        return onIndoorFloorSwtichListener;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setOnIndoorFloorListener(
 | 
				
			||||||
 | 
					            OnIndoorFloorListener onIndoorFloorSwtichListener) {
 | 
				
			||||||
 | 
					        this.onIndoorFloorSwtichListener = onIndoorFloorSwtichListener;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static abstract interface OnIndoorFloorListener {
 | 
				
			||||||
 | 
					        public abstract void onSelected(int selectedIndex);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // utils
 | 
				
			||||||
 | 
					    public static int dip2px(Context context, float dpValue) {
 | 
				
			||||||
 | 
					        final float scale = context.getResources().getDisplayMetrics().density;
 | 
				
			||||||
 | 
					        return (int) (dpValue * scale + 0.5f);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static int px2dip(Context context, float pxValue) {
 | 
				
			||||||
 | 
					        final float scale = context.getResources().getDisplayMetrics().density;
 | 
				
			||||||
 | 
					        return (int) (pxValue / scale + 0.5f);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取控件的高度,如果获取的高度为0,则重新计算尺寸后再返回高度
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param view
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static int getViewMeasuredHeight(View view) {
 | 
				
			||||||
 | 
					        calcViewMeasure(view);
 | 
				
			||||||
 | 
					        return view.getMeasuredHeight();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取控件的宽度,如果获取的宽度为0,则重新计算尺寸后再返回宽度
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param view
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static int getViewMeasuredWidth(View view) {
 | 
				
			||||||
 | 
					        calcViewMeasure(view);
 | 
				
			||||||
 | 
					        return view.getMeasuredWidth();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 测量控件的尺寸
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param view
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public static void calcViewMeasure(View view) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int width = MeasureSpec.makeMeasureSpec(0,
 | 
				
			||||||
 | 
					                MeasureSpec.UNSPECIFIED);
 | 
				
			||||||
 | 
					        int expandSpec = MeasureSpec.makeMeasureSpec(
 | 
				
			||||||
 | 
					                Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
 | 
				
			||||||
 | 
					        view.measure(width, expandSpec);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setVisible(boolean isEnable) {
 | 
				
			||||||
 | 
					        if (isEnable) {
 | 
				
			||||||
 | 
					            if(!isVisible()) {
 | 
				
			||||||
 | 
					                setVisibility(VISIBLE);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            if(isVisible())
 | 
				
			||||||
 | 
					                setVisibility(GONE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public boolean isVisible() {
 | 
				
			||||||
 | 
					        return getVisibility() == VISIBLE ? true : false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,198 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.basic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.os.Handler;
 | 
				
			||||||
 | 
					import android.text.TextUtils;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.UiSettings;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.IndoorBuilding;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.IndoorInfo;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.IndoorLevel;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.MapPoi;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.Marker;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterItem;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.vector.utils.clustering.ClusterManager;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.vector.utils.clustering.algo.NonHierarchicalDistanceBasedAlgorithm;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.vector.utils.clustering.view.DefaultClusterRenderer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class IndoorMapActivity extends AppCompatActivity implements TencentMap.OnIndoorStateChangeListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String TAG = "IndoorMapActivity";
 | 
				
			||||||
 | 
					    private MapView mapView;
 | 
				
			||||||
 | 
					    private TencentMap tencentMap;
 | 
				
			||||||
 | 
					    private IndoorFloorView indoorFloorView;
 | 
				
			||||||
 | 
					    private UiSettings uiSettings;
 | 
				
			||||||
 | 
					    private Handler handler = new Handler();
 | 
				
			||||||
 | 
					    private String floorName;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_indoor);
 | 
				
			||||||
 | 
					        mapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        indoorFloorView = findViewById(R.id.indoor_floor);
 | 
				
			||||||
 | 
					        if (tencentMap == null) {
 | 
				
			||||||
 | 
					            tencentMap = mapView.getMap();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //欧美汇室内地图,需Key开通室内地图权限
 | 
				
			||||||
 | 
					        CameraUpdate camera =
 | 
				
			||||||
 | 
					                CameraUpdateFactory.newCameraPosition(new CameraPosition(
 | 
				
			||||||
 | 
					                        new LatLng(39.979382, 116.314106),
 | 
				
			||||||
 | 
					                        18,
 | 
				
			||||||
 | 
					                        0f,
 | 
				
			||||||
 | 
					                        0f));
 | 
				
			||||||
 | 
					        tencentMap.moveCamera(camera);
 | 
				
			||||||
 | 
					        final ArrayList<MarkerCluster> markerClusters = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        uiSettings = tencentMap.getUiSettings();
 | 
				
			||||||
 | 
					        tencentMap.setIndoorEnabled(true);
 | 
				
			||||||
 | 
					        //设置室内蒙层颜色 sdk版本4.3.5新增接口
 | 
				
			||||||
 | 
					        tencentMap.setIndoorMaskColor(R.color.color_C71585);
 | 
				
			||||||
 | 
					        //设置室内图状态变化监听
 | 
				
			||||||
 | 
					        tencentMap.setOnIndoorStateChangeListener(this);
 | 
				
			||||||
 | 
					        tencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
 | 
				
			||||||
 | 
					        //设置是否隐藏楼层控件
 | 
				
			||||||
 | 
					        uiSettings.setIndoorLevelPickerEnabled(false);
 | 
				
			||||||
 | 
					        indoorFloorView.setOnIndoorFloorListener(new MyIndoorViewAdapter());
 | 
				
			||||||
 | 
					        ClusterManager<MarkerCluster> markerClusterClusterManager = new ClusterManager<MarkerCluster>(this, tencentMap);
 | 
				
			||||||
 | 
					        NonHierarchicalDistanceBasedAlgorithm<MarkerCluster> nba = new NonHierarchicalDistanceBasedAlgorithm<>(this);
 | 
				
			||||||
 | 
					        nba.setMaxDistanceAtZoom(15);
 | 
				
			||||||
 | 
					        markerClusterClusterManager.setAlgorithm(nba);
 | 
				
			||||||
 | 
					        DefaultClusterRenderer<MarkerCluster> renderer = new DefaultClusterRenderer<>(this, tencentMap, markerClusterClusterManager);
 | 
				
			||||||
 | 
					        renderer.setMinClusterSize(2);
 | 
				
			||||||
 | 
					        renderer.setBuckets(new int[]{5, 10, 20});
 | 
				
			||||||
 | 
					        markerClusterClusterManager.setRenderer(renderer);
 | 
				
			||||||
 | 
					        //添加室内图marker
 | 
				
			||||||
 | 
					        tencentMap.setOnMapPoiClickListener(new TencentMap.OnMapPoiClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onClicked(MapPoi mapPoi) {
 | 
				
			||||||
 | 
					                LatLng position = mapPoi.getPosition();
 | 
				
			||||||
 | 
					                MarkerOptions markerOptions = new MarkerOptions().position(position).title(mapPoi.name).infoWindowEnable(true);
 | 
				
			||||||
 | 
					                if (!TextUtils.isEmpty("F3")) {
 | 
				
			||||||
 | 
					                    markerOptions.indoorInfo(new IndoorInfo("11000023805", "F3"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Marker marker = tencentMap.addMarker(markerOptions);
 | 
				
			||||||
 | 
					                LatLng position1 = mapPoi.getPosition();
 | 
				
			||||||
 | 
					                markerClusters.add(new MarkerCluster(position1.getLatitude(), position1.getLongitude()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        tencentMap.setOnCameraChangeListener(markerClusterClusterManager);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onIndoorBuildingFocused() {
 | 
				
			||||||
 | 
					        Log.d(TAG, "onIndoorBuildingFocused: 室内图场景激活回调");
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onIndoorLevelActivated(final IndoorBuilding indoorBuilding) {
 | 
				
			||||||
 | 
					        if (indoorBuilding != null) {
 | 
				
			||||||
 | 
					            handler.post(new Runnable() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void run() {
 | 
				
			||||||
 | 
					                    indoorFloorView.setVisible(true);
 | 
				
			||||||
 | 
					                    if (mIndoorBuilding == null || !mIndoorBuilding.getBuidlingId().equals(indoorBuilding.getBuidlingId())) {
 | 
				
			||||||
 | 
					                        List<IndoorLevel> levels = indoorBuilding.getLevels();
 | 
				
			||||||
 | 
					                        String[] activedIndoorFloorNames1 = tencentMap.getActivedIndoorFloorNames();
 | 
				
			||||||
 | 
					                        indoorFloorView.setItems(activedIndoorFloorNames1);
 | 
				
			||||||
 | 
					                        for (int i = 0; i < levels.size(); i++) {
 | 
				
			||||||
 | 
					                            floorName = levels.get(i).getName();
 | 
				
			||||||
 | 
					                            indoorFloorView.setSeletion(floorName);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    mIndoorBuilding = indoorBuilding;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            indoorFloorView.setVisible(false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onIndoorBuildingDeactivated() {
 | 
				
			||||||
 | 
					        Log.d(TAG, "onIndoorBuildingDeactivated: 当前室内图处于无效状态");
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    IndoorBuilding mIndoorBuilding = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private class MyIndoorViewAdapter implements IndoorFloorView.OnIndoorFloorListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onSelected(int selectedIndex) {
 | 
				
			||||||
 | 
					            if (mIndoorBuilding != null) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                List<IndoorLevel> levels = mIndoorBuilding.getLevels();
 | 
				
			||||||
 | 
					                String activedIndoorFloorName = tencentMap.getActivedIndoorFloorNames()[selectedIndex];
 | 
				
			||||||
 | 
					                String name = levels.get(selectedIndex).getName();
 | 
				
			||||||
 | 
					                name = activedIndoorFloorName;
 | 
				
			||||||
 | 
					                String buidlingId = mIndoorBuilding.getBuidlingId();
 | 
				
			||||||
 | 
					                tencentMap.setIndoorFloor(buidlingId, name);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MarkerCluster implements ClusterItem {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final LatLng latLng;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public MarkerCluster(double lat, double longitude) {
 | 
				
			||||||
 | 
					        latLng = new LatLng(lat, longitude);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public LatLng getPosition() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return latLng;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,109 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,195 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * 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 cc.winboll.studio.positions.demo.basic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.annotation.SuppressLint;
 | 
				
			||||||
 | 
					import android.graphics.PorterDuff;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.AdapterView;
 | 
				
			||||||
 | 
					import android.widget.ArrayAdapter;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
 | 
					import android.widget.RadioGroup;
 | 
				
			||||||
 | 
					import android.widget.Spinner;
 | 
				
			||||||
 | 
					import android.widget.Switch;
 | 
				
			||||||
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.fragment.app.FragmentActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Demonstrates the different base layers of a map.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					@SuppressLint("NewApi")
 | 
				
			||||||
 | 
					public class MapStyleDemoActivity extends FragmentActivity implements TencentMap.OnCameraChangeListener {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TextView mTextView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private Switch mSwitch;
 | 
				
			||||||
 | 
					    private Spinner mSpinner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private String[] styles = new String[]{"style1", "style2", "style3", "style4", "style5",
 | 
				
			||||||
 | 
					            "normal", "traffic_navi", "traffic_navi_night", "satellite", "night", "navi", "night", "eagle_day", "eagle_night"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_map_style);
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.map_view);
 | 
				
			||||||
 | 
					        mTextView = findViewById(R.id.tv_level);
 | 
				
			||||||
 | 
					        mSwitch=findViewById(R.id.switch_open);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.901268, 116.403854), 11f, 0f, 0f));
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(cameraUpdate);
 | 
				
			||||||
 | 
					        //mTencentMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(39.901268, 116.403854))); //移动地图
 | 
				
			||||||
 | 
					        mTencentMap.setOnCameraChangeListener(this);
 | 
				
			||||||
 | 
					        mSpinner = findViewById(R.id.sp_style);
 | 
				
			||||||
 | 
					        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles);
 | 
				
			||||||
 | 
					        mSpinner.setAdapter(adapter);
 | 
				
			||||||
 | 
					        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
 | 
				
			||||||
 | 
					                if (position < 5) {
 | 
				
			||||||
 | 
					                    mTencentMap.setMapStyle(position + 1);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                switch (position) {
 | 
				
			||||||
 | 
					                    case 5:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NORMAL);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 6:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NAVI);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 7:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_TRAFFIC_NIGHT);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 8:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_SATELLITE);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 9:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NIGHT);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 10:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(TencentMap.MAP_TYPE_NAVI);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 11:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(13 + 1000);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 12:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(14 + 1000);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 13:
 | 
				
			||||||
 | 
					                        mTencentMap.setMapStyle(15 + 1000);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onNothingSelected(AdapterView<?> parent) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        RadioGroup rg = findViewById(R.id.rg_map_type);
 | 
				
			||||||
 | 
					        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onCheckedChanged(RadioGroup group, int checkedId) {
 | 
				
			||||||
 | 
					                switch (checkedId) {
 | 
				
			||||||
 | 
					                    case R.id.rb_normal_type:
 | 
				
			||||||
 | 
					                        if (mTencentMap != null) {
 | 
				
			||||||
 | 
					                            mTencentMap.setMapType(TencentMap.MAP_TYPE_NORMAL);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case R.id.rb_dark_type:
 | 
				
			||||||
 | 
					                        if (mTencentMap != null) {
 | 
				
			||||||
 | 
					                            mTencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case R.id.rb_sagellite_type:
 | 
				
			||||||
 | 
					                        if (mTencentMap != null) {
 | 
				
			||||||
 | 
					                            mTencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        mTencentMap.getUiSettings().setCompassEnabled(true);
 | 
				
			||||||
 | 
					        mTencentMap.getUiSettings().setMyLocationButtonEnabled(true);
 | 
				
			||||||
 | 
					        mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
 | 
				
			||||||
 | 
					                PorterDuff.Mode buttonTintMode = compoundButton.getButtonTintMode();
 | 
				
			||||||
 | 
					                if(b){
 | 
				
			||||||
 | 
					                    mTencentMap.setBuildingEnable(true);
 | 
				
			||||||
 | 
					                }else{
 | 
				
			||||||
 | 
					                    mTencentMap.setBuildingEnable(false);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onCameraChange(CameraPosition cameraPosition) {
 | 
				
			||||||
 | 
					        Log.i("TAG","地图滑动了");
 | 
				
			||||||
 | 
					        mTextView.setText("当前缩放级别为:" + cameraPosition.zoom);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onCameraChangeFinished(CameraPosition cameraPosition) {
 | 
				
			||||||
 | 
					        Log.i("TAG","地图滑动了");
 | 
				
			||||||
 | 
					        mTextView.setText("当前缩放级别为:" + cameraPosition.zoom);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,79 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,559 @@
 | 
				
			|||||||
 | 
					//package cc.winboll.studio.positions.demo.basic;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					//import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					//import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					//import androidx.recyclerview.widget.DividerItemDecoration;
 | 
				
			||||||
 | 
					//import androidx.recyclerview.widget.LinearLayoutManager;
 | 
				
			||||||
 | 
					//import androidx.recyclerview.widget.RecyclerView;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//import android.content.BroadcastReceiver;
 | 
				
			||||||
 | 
					//import android.content.Context;
 | 
				
			||||||
 | 
					//import android.content.Intent;
 | 
				
			||||||
 | 
					//import android.content.IntentFilter;
 | 
				
			||||||
 | 
					//import android.net.ConnectivityManager;
 | 
				
			||||||
 | 
					//import android.net.NetworkInfo;
 | 
				
			||||||
 | 
					//import android.os.Build;
 | 
				
			||||||
 | 
					//import android.os.Bundle;
 | 
				
			||||||
 | 
					//import android.os.Handler;
 | 
				
			||||||
 | 
					//import android.os.Message;
 | 
				
			||||||
 | 
					//import android.util.Log;
 | 
				
			||||||
 | 
					//import android.view.LayoutInflater;
 | 
				
			||||||
 | 
					//import android.view.Menu;
 | 
				
			||||||
 | 
					//import android.view.MenuItem;
 | 
				
			||||||
 | 
					//import android.view.View;
 | 
				
			||||||
 | 
					//import android.view.ViewGroup;
 | 
				
			||||||
 | 
					//import android.widget.Button;
 | 
				
			||||||
 | 
					//import android.widget.LinearLayout;
 | 
				
			||||||
 | 
					//import android.widget.TextView;
 | 
				
			||||||
 | 
					//import android.widget.Toast;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineItem;
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineItemController;
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineMapComponent;
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineMapSyncedListener;
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineStatus;
 | 
				
			||||||
 | 
					//import com.tencent.map.sdk.comps.offlinemap.OfflineStatusChangedListener;
 | 
				
			||||||
 | 
					//import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
 | 
				
			||||||
 | 
					//import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//import java.util.ArrayList;
 | 
				
			||||||
 | 
					//import java.util.List;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					///**
 | 
				
			||||||
 | 
					// * 离线地图下载、取消下载、删除
 | 
				
			||||||
 | 
					// */
 | 
				
			||||||
 | 
					//public class OfflineMapActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					//    private static final String TAG = "OfflineMapActivity";
 | 
				
			||||||
 | 
					//    private Button btnGoWork;
 | 
				
			||||||
 | 
					//    private Button btnZoomIn;
 | 
				
			||||||
 | 
					//    private Button btnZoomOut;
 | 
				
			||||||
 | 
					//    private Button btnReboot;
 | 
				
			||||||
 | 
					//    private Button btnSync;
 | 
				
			||||||
 | 
					//    private Button btnRefresh;
 | 
				
			||||||
 | 
					//    private MapView mapView;
 | 
				
			||||||
 | 
					//    private RecyclerView offlineItemRecycleView;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private TencentMap map;
 | 
				
			||||||
 | 
					//    private OfflineMapComponent offlineComp;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private OfflineAdapter offlineAdapter;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private List<OfflineItem> offlineItems = new ArrayList<>();
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private IntentFilter intentFilter;
 | 
				
			||||||
 | 
					//    private NetworkChangeReceiver networkChangeReceiver;
 | 
				
			||||||
 | 
					//    private ConnectivityManager connectivityManager;
 | 
				
			||||||
 | 
					//    private TextView tvParmes;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onCreate(@Nullable Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					//        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					//        setContentView(R.layout.activity_offline_map);
 | 
				
			||||||
 | 
					//        btnGoWork = findViewById(R.id.btn_go_work);
 | 
				
			||||||
 | 
					//        btnZoomIn = findViewById(R.id.btn_zoom_in);
 | 
				
			||||||
 | 
					//        btnZoomOut = findViewById(R.id.btn_zoom_out);
 | 
				
			||||||
 | 
					//        btnReboot = findViewById(R.id.btn_reboot_map);
 | 
				
			||||||
 | 
					//        btnSync = findViewById(R.id.btn_sync);
 | 
				
			||||||
 | 
					//        btnRefresh = findViewById(R.id.btn_refresh);
 | 
				
			||||||
 | 
					//        mapView = findViewById(R.id.map_view);
 | 
				
			||||||
 | 
					//        tvParmes = findViewById(R.id.tv_parmes);
 | 
				
			||||||
 | 
					//        offlineItemRecycleView = findViewById(R.id.offline_item_list);
 | 
				
			||||||
 | 
					//        connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        initMap();
 | 
				
			||||||
 | 
					//        //重置地图
 | 
				
			||||||
 | 
					//        btnReboot.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View v) {
 | 
				
			||||||
 | 
					//                if (map != null) {
 | 
				
			||||||
 | 
					//                    mapView.onPause();
 | 
				
			||||||
 | 
					//                    mapView.onStop();
 | 
				
			||||||
 | 
					//                    mapView.onDestroy();
 | 
				
			||||||
 | 
					//                    map = null;
 | 
				
			||||||
 | 
					//                    initMap();
 | 
				
			||||||
 | 
					//                    mapView.onStart();
 | 
				
			||||||
 | 
					//                    mapView.onResume();
 | 
				
			||||||
 | 
					//                    tvParmes.setText("重置地图");
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        offlineAdapter = new OfflineAdapter(offlineItems);
 | 
				
			||||||
 | 
					//        offlineItemRecycleView.setLayoutManager(new LinearLayoutManager(this));
 | 
				
			||||||
 | 
					//        offlineItemRecycleView.setAdapter(offlineAdapter);
 | 
				
			||||||
 | 
					//        offlineItemRecycleView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
 | 
				
			||||||
 | 
					//        intentFilter = new IntentFilter();
 | 
				
			||||||
 | 
					//        intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
 | 
				
			||||||
 | 
					//        networkChangeReceiver = new NetworkChangeReceiver();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void initMap() {
 | 
				
			||||||
 | 
					//        // 设置离线地图
 | 
				
			||||||
 | 
					//        TencentMapOptions options = new TencentMapOptions();
 | 
				
			||||||
 | 
					//        options.setOfflineMapEnable(true);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        map = mapView.getMap(options);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        map.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onMapLoaded() {
 | 
				
			||||||
 | 
					//                Toast.makeText(OfflineMapActivity.this, "地图加载完成", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//        //获取离线地图的城市列表
 | 
				
			||||||
 | 
					//        offlineComp = map.getMapComponent(OfflineMapComponent.class);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        Log.d(TAG, "Offline enable:" + offlineComp.isOfflineMapEnable());
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        // 回公司按钮
 | 
				
			||||||
 | 
					//        btnGoWork.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View view) {
 | 
				
			||||||
 | 
					//                List<LatLng> latLngs = new ArrayList<>();
 | 
				
			||||||
 | 
					//                latLngs.add(new LatLng(40.042893, 116.269673));
 | 
				
			||||||
 | 
					//                latLngs.add(new LatLng(40.038951, 116.275241));
 | 
				
			||||||
 | 
					//                LatLng center = new LatLng(40.040429, 116.273525);
 | 
				
			||||||
 | 
					//                map.addMarker(new MarkerOptions(center)
 | 
				
			||||||
 | 
					//                        .anchor(0.5f, 1));
 | 
				
			||||||
 | 
					//                map.moveCamera(CameraUpdateFactory.newLatLngBoundsWithMapCenter(
 | 
				
			||||||
 | 
					//                        new LatLngBounds.Builder()
 | 
				
			||||||
 | 
					//                                .include(latLngs)
 | 
				
			||||||
 | 
					//                                .build(),
 | 
				
			||||||
 | 
					//                        center,
 | 
				
			||||||
 | 
					//                        100));
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        // 地图放大按钮
 | 
				
			||||||
 | 
					//        btnZoomIn.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View view) {
 | 
				
			||||||
 | 
					//                map.moveCamera(CameraUpdateFactory.zoomIn());
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        // 地图缩小按钮
 | 
				
			||||||
 | 
					//        btnZoomOut.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View view) {
 | 
				
			||||||
 | 
					//                map.moveCamera(CameraUpdateFactory.zoomOut());
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        // 同步离线地图信息按钮
 | 
				
			||||||
 | 
					//        btnSync.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View view) {
 | 
				
			||||||
 | 
					//                syncData();
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        // 刷新离线地图列表按钮
 | 
				
			||||||
 | 
					//        btnRefresh.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onClick(View view) {
 | 
				
			||||||
 | 
					//                offlineItemRecycleView.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					//                refreshOfflineList();
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//        map.moveCamera(CameraUpdateFactory.zoomTo(5));  // 设置缩放级别,显示全国概略图.
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onStart() {
 | 
				
			||||||
 | 
					//        super.onStart();
 | 
				
			||||||
 | 
					//        mapView.onStart();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onResume() {
 | 
				
			||||||
 | 
					//        super.onResume();
 | 
				
			||||||
 | 
					//        mapView.onResume();
 | 
				
			||||||
 | 
					//        registerReceiver(networkChangeReceiver, intentFilter);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					////        offlineItems.addAll(offlineComp.getOfflineItemList());
 | 
				
			||||||
 | 
					////        tryToOpenOffline();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onPause() {
 | 
				
			||||||
 | 
					//        super.onPause();
 | 
				
			||||||
 | 
					//        mapView.onPause();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onStop() {
 | 
				
			||||||
 | 
					//        super.onStop();
 | 
				
			||||||
 | 
					//        mapView.onStop();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onDestroy() {
 | 
				
			||||||
 | 
					//        super.onDestroy();
 | 
				
			||||||
 | 
					//        mapView.onDestroy();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private class OfflineAdapter extends RecyclerView.Adapter<OfflineAdapter.OfflineViewHolder> {
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        List<OfflineItem> offlineItems;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        OfflineAdapter(List<OfflineItem> offlineItems) {
 | 
				
			||||||
 | 
					//            this.offlineItems = offlineItems;
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        @NonNull
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public OfflineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
 | 
				
			||||||
 | 
					//            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_offline
 | 
				
			||||||
 | 
					//                    , parent, false);
 | 
				
			||||||
 | 
					//            return new OfflineViewHolder(view);
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public void onBindViewHolder(@NonNull OfflineViewHolder holder, int position) {
 | 
				
			||||||
 | 
					//            final OfflineItem offlineItem = offlineItems.get(position);
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            final OfflineItemController cityController =
 | 
				
			||||||
 | 
					//                    offlineComp.getOfflineItemController(offlineItem, statusChangedListener);
 | 
				
			||||||
 | 
					//            if (cityController == null) {
 | 
				
			||||||
 | 
					//                holder.tvTitle.setText("【controller is null】" + offlineItem.toString());
 | 
				
			||||||
 | 
					//                return;
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            holder.tvTitle.setText(offlineItem.toString());
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            holder.btnSwitch.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//                @Override
 | 
				
			||||||
 | 
					//                public void onClick(View v) {
 | 
				
			||||||
 | 
					//                    boolean isClosed = cityController.close();
 | 
				
			||||||
 | 
					//                    if (isClosed) {
 | 
				
			||||||
 | 
					//                        //  toast("已关闭【" + offlineItem.getName() + "】的离线地图");
 | 
				
			||||||
 | 
					//                        tvParmes.setText("已关闭【" + offlineItem.getName() + "】的离线地图");
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                    Log.d(TAG, offlineItem.getName() + " close offline:" + isClosed);
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            holder.btnDownload.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//                @Override
 | 
				
			||||||
 | 
					//                public void onClick(View v) {
 | 
				
			||||||
 | 
					//                    downloadOffline(offlineItem);
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            });
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            holder.btnDelete.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					//                @Override
 | 
				
			||||||
 | 
					//                public void onClick(View v) {
 | 
				
			||||||
 | 
					//                    boolean isDeleted = cityController.removeCache();
 | 
				
			||||||
 | 
					//                    if (isDeleted) {
 | 
				
			||||||
 | 
					//                        // toast("缓存移除成功");
 | 
				
			||||||
 | 
					//                        tvParmes.setText("缓存移除成功");
 | 
				
			||||||
 | 
					//                    } else {
 | 
				
			||||||
 | 
					//                        // toast("缓存移除失败");
 | 
				
			||||||
 | 
					//                        tvParmes.setText("缓存移除失败");
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                    Log.d(TAG, offlineItem.getName() + " remove cache:" + isDeleted);
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            });
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public int getItemCount() {
 | 
				
			||||||
 | 
					//            return offlineItems.size();
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        class OfflineViewHolder extends RecyclerView.ViewHolder {
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            TextView tvTitle;
 | 
				
			||||||
 | 
					//            Button btnSwitch;
 | 
				
			||||||
 | 
					//            Button btnDownload;
 | 
				
			||||||
 | 
					//            Button btnDelete;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            public OfflineViewHolder(@NonNull View itemView) {
 | 
				
			||||||
 | 
					//                super(itemView);
 | 
				
			||||||
 | 
					//                tvTitle = itemView.findViewById(R.id.tv_offline_title);
 | 
				
			||||||
 | 
					//                btnSwitch = itemView.findViewById(R.id.btn_switch_offline);
 | 
				
			||||||
 | 
					//                btnDownload = itemView.findViewById(R.id.btn_download_offline);
 | 
				
			||||||
 | 
					//                btnDelete = itemView.findViewById(R.id.btn_delete_offline);
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    OfflineStatusChangedListener statusChangedListener = new OfflineStatusChangedListener() {
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public void onStatusChanged(OfflineItem offlineItem, OfflineStatus offlineStatus) {
 | 
				
			||||||
 | 
					//            Log.d(TAG, offlineItem.getName() + " onStatusChanged: " + offlineStatus);
 | 
				
			||||||
 | 
					//            final Message msg = new Message();
 | 
				
			||||||
 | 
					//            msg.obj = offlineItem;
 | 
				
			||||||
 | 
					//            switch (offlineStatus) {
 | 
				
			||||||
 | 
					//                case OPEN: //开始离线
 | 
				
			||||||
 | 
					//                    new Thread(new Runnable() {
 | 
				
			||||||
 | 
					//                        @Override
 | 
				
			||||||
 | 
					//                        public void run() {
 | 
				
			||||||
 | 
					//                            msg.what = STATE_OPEN;
 | 
				
			||||||
 | 
					//                            mHandler.sendMessage(msg);
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }).start();
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case CLOSE: //关闭离线
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case COMPLETED: //完成下载
 | 
				
			||||||
 | 
					//                    new Thread(new Runnable() {
 | 
				
			||||||
 | 
					//                        @Override
 | 
				
			||||||
 | 
					//                        public void run() {
 | 
				
			||||||
 | 
					//                            msg.what = STATE_COMPLETED;
 | 
				
			||||||
 | 
					//                            mHandler.sendMessage(msg);
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }).start();
 | 
				
			||||||
 | 
					//                    if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("china2")) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        cityController.open();
 | 
				
			||||||
 | 
					//                        map.moveCamera(CameraUpdateFactory.zoomTo(5));  // 设置缩放级别,显示全国概略图.
 | 
				
			||||||
 | 
					//                    } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("beijingshi")) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        cityController.open();
 | 
				
			||||||
 | 
					//                        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.909018, 116.397427), 16));
 | 
				
			||||||
 | 
					//                    } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("shanghaishi")) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        cityController.open();
 | 
				
			||||||
 | 
					//                        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(31.230378, 121.473658), 16));
 | 
				
			||||||
 | 
					//                    } else if (offlineItem.getPercentage() == 100 && offlineItem.getPinyin().equals("tianjinshi")) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        cityController.open();
 | 
				
			||||||
 | 
					//                        map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.085294, 117.201538), 16));
 | 
				
			||||||
 | 
					//                    } else {
 | 
				
			||||||
 | 
					//                        toast("可参考demo自行移动视野范围");
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case CANCEL: //取消下载
 | 
				
			||||||
 | 
					//                    toast("取消下载");
 | 
				
			||||||
 | 
					//                    new Thread(new Runnable() {
 | 
				
			||||||
 | 
					//                        @Override
 | 
				
			||||||
 | 
					//                        public void run() {
 | 
				
			||||||
 | 
					//                            msg.what = STATE_CANCEL;
 | 
				
			||||||
 | 
					//                            mHandler.sendMessage(msg);
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }).start();
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case DOWNLOADING: //下载中
 | 
				
			||||||
 | 
					//                    new Thread(new Runnable() {
 | 
				
			||||||
 | 
					//                        @Override
 | 
				
			||||||
 | 
					//                        public void run() {
 | 
				
			||||||
 | 
					//                            msg.what = STATE_DOWNLOAD;
 | 
				
			||||||
 | 
					//                            mHandler.sendMessage(msg);
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }).start();
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case ERROR: //离线错误
 | 
				
			||||||
 | 
					//                    toast("离线错误");
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case READY: //准备下载
 | 
				
			||||||
 | 
					//                    toast("准备下载");
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case START: //开始下载
 | 
				
			||||||
 | 
					//                    msg.what = STATE_START;
 | 
				
			||||||
 | 
					//                    mHandler.sendMessage(msg);
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    };
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void refreshOfflineList() {
 | 
				
			||||||
 | 
					//        //获取离线地图列表
 | 
				
			||||||
 | 
					//        List<OfflineItem> offlineItems = offlineComp.getOfflineItemList();
 | 
				
			||||||
 | 
					//        Log.d(TAG, "Offline Items num:" + offlineItems.size());
 | 
				
			||||||
 | 
					////        for (OfflineItem item : offlineItems) {
 | 
				
			||||||
 | 
					////            Log.d(TAG,  item.toString());
 | 
				
			||||||
 | 
					////        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        this.offlineItems.clear();
 | 
				
			||||||
 | 
					//        this.offlineItems.addAll(offlineItems);
 | 
				
			||||||
 | 
					//        offlineAdapter.notifyDataSetChanged();
 | 
				
			||||||
 | 
					//        toast("刷新离线地图列表");
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void tryToOpenOffline() {
 | 
				
			||||||
 | 
					//        // 无网情况主动开启离线地图
 | 
				
			||||||
 | 
					//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
 | 
				
			||||||
 | 
					//            if (connectivityManager.getActiveNetwork() == null) {
 | 
				
			||||||
 | 
					//                Log.d(TAG, "tryToOpenOffline: 无网络,尝试开启离线地图,item size:" + offlineItems.size());
 | 
				
			||||||
 | 
					//                for (OfflineItem item : offlineItems) {
 | 
				
			||||||
 | 
					//                    if (item.getPercentage() == 100 && item.getPinyin().equals("beijingshi")) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(item,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        if (cityController == null) {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + "try: controller is null");
 | 
				
			||||||
 | 
					//                        } else {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + "try: openOffline: " + cityController.open());
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        } else {
 | 
				
			||||||
 | 
					//            toast("require API > M(23)");
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void closeOffline() {
 | 
				
			||||||
 | 
					//        List<OfflineItem> items = offlineComp.getOfflineItemList();
 | 
				
			||||||
 | 
					//        Log.d(TAG, "closeOffline: ,item size:" + items.size());
 | 
				
			||||||
 | 
					//        for (OfflineItem item : items) {
 | 
				
			||||||
 | 
					//            if (item.getPercentage() == 100) {
 | 
				
			||||||
 | 
					//                OfflineItemController cityController = offlineComp.getOfflineItemController(item,
 | 
				
			||||||
 | 
					//                        statusChangedListener);
 | 
				
			||||||
 | 
					//                if (cityController == null) {
 | 
				
			||||||
 | 
					//                    Log.d(TAG, item.getName() + "close: controller is null");
 | 
				
			||||||
 | 
					//                } else {
 | 
				
			||||||
 | 
					//                    Log.d(TAG, item.getName() + "close: close Offline: " + cityController.close());
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void syncData() {
 | 
				
			||||||
 | 
					//        //同步最新数据
 | 
				
			||||||
 | 
					//        offlineComp.syncLatestData(new OfflineMapSyncedListener() {
 | 
				
			||||||
 | 
					//            @Override
 | 
				
			||||||
 | 
					//            public void onSynced(boolean b) {
 | 
				
			||||||
 | 
					//                Log.d(TAG, "onSynced: " + b);
 | 
				
			||||||
 | 
					//                refreshOfflineList();
 | 
				
			||||||
 | 
					//                // tryToOpenOffline();
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void downloadOffline(OfflineItem offlineItem) {
 | 
				
			||||||
 | 
					//        //获取某一Item的离线地图数据
 | 
				
			||||||
 | 
					//        OfflineItemController cityController = offlineComp.getOfflineItemController(offlineItem, statusChangedListener);
 | 
				
			||||||
 | 
					//        if (cityController == null) {
 | 
				
			||||||
 | 
					//            Toast.makeText(this, "cityController为NULL", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					//            return;
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        boolean needDownload = cityController.checkInvalidate();
 | 
				
			||||||
 | 
					//        Log.d(TAG, "need download:" + cityController.checkInvalidate());
 | 
				
			||||||
 | 
					//        if (needDownload) {
 | 
				
			||||||
 | 
					//            //执行下载
 | 
				
			||||||
 | 
					//            cityController.startDownload();
 | 
				
			||||||
 | 
					//            tvParmes.setText("开始下载【" + offlineItem.getName() + "】的离线地图");
 | 
				
			||||||
 | 
					//        } else {
 | 
				
			||||||
 | 
					//            //跳过更新,打开离线
 | 
				
			||||||
 | 
					//            boolean isOpened = cityController.open();
 | 
				
			||||||
 | 
					//            if (isOpened) {
 | 
				
			||||||
 | 
					//                tvParmes.setText("已开启【" + offlineItem.getName() + "】的离线地图");
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//            Log.d(TAG, offlineItem.getName() + " open offline:" + isOpened);
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private final class NetworkChangeReceiver extends BroadcastReceiver {
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public void onReceive(Context context, Intent intent) {
 | 
				
			||||||
 | 
					//            NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
 | 
				
			||||||
 | 
					//            //获取离线那地图列表
 | 
				
			||||||
 | 
					//            List<OfflineItem> items = offlineComp.getOfflineItemList();
 | 
				
			||||||
 | 
					//            Log.d(TAG, "onReceive: 网络状态变化, offline item size:" + items.size());
 | 
				
			||||||
 | 
					//            if (networkInfo != null) {
 | 
				
			||||||
 | 
					//                Toast.makeText(context, "当前无网络连接", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					//                for (OfflineItem item : items) {
 | 
				
			||||||
 | 
					//                    if (item.getPercentage() == 100) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(item,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        if (cityController == null) {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + " controller is null");
 | 
				
			||||||
 | 
					//                        } else {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + " closeOffline: " + cityController.close());
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            } else {
 | 
				
			||||||
 | 
					//                // 加载所有已下载的离线地图
 | 
				
			||||||
 | 
					//                items = offlineComp.getOfflineItemList();
 | 
				
			||||||
 | 
					//                for (OfflineItem item : items) {
 | 
				
			||||||
 | 
					//                    if (item.getPercentage() == 100) {
 | 
				
			||||||
 | 
					//                        OfflineItemController cityController = offlineComp.getOfflineItemController(item,
 | 
				
			||||||
 | 
					//                                statusChangedListener);
 | 
				
			||||||
 | 
					//                        if (cityController == null) {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + " controller is null");
 | 
				
			||||||
 | 
					//                        } else {
 | 
				
			||||||
 | 
					//                            Log.d(TAG, item.getName() + " openOffline: " + cityController.open());
 | 
				
			||||||
 | 
					//                        }
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                }
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private final int STATE_DOWNLOAD = 1;
 | 
				
			||||||
 | 
					//    private final int STATE_COMPLETED = 2;
 | 
				
			||||||
 | 
					//    private final int STATE_OPEN = 3;
 | 
				
			||||||
 | 
					//    private final int STATE_CANCEL = 4;
 | 
				
			||||||
 | 
					//    private final int STATE_START = 5;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private Handler mHandler = new Handler() {
 | 
				
			||||||
 | 
					//        public void handleMessage(Message msg) {
 | 
				
			||||||
 | 
					//            OfflineItem item = (OfflineItem) msg.obj;
 | 
				
			||||||
 | 
					//            switch (msg.what) {
 | 
				
			||||||
 | 
					//                case STATE_DOWNLOAD:
 | 
				
			||||||
 | 
					//                    if (item.getPercentage() % 10 == 0) {
 | 
				
			||||||
 | 
					//                        tvParmes.setText("正在下载【" + item.getName() + "】离线地图:" + item.getPercentage() + "%");
 | 
				
			||||||
 | 
					//                        Log.d("getPercentage", item.getPercentage() + "");
 | 
				
			||||||
 | 
					//                    }
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case STATE_COMPLETED:
 | 
				
			||||||
 | 
					//                    tvParmes.setText(item.getName() + "离线地图下载结束");
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case STATE_OPEN:
 | 
				
			||||||
 | 
					//                    tvParmes.setText(item.getName() + "离线地图已开启 ");
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case STATE_CANCEL:
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//                case STATE_START:
 | 
				
			||||||
 | 
					//                    tvParmes.setText(item.getName() + "离线地图开始下载,点击刷新列表查看进度");
 | 
				
			||||||
 | 
					//                    break;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    };
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private void toast(String msg) {
 | 
				
			||||||
 | 
					//        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//}
 | 
				
			||||||
@@ -0,0 +1,91 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.basic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.fragment.app.FragmentActivity;
 | 
				
			||||||
 | 
					import androidx.recyclerview.widget.LinearLayoutManager;
 | 
				
			||||||
 | 
					import androidx.recyclerview.widget.RecyclerView;
 | 
				
			||||||
 | 
					import android.content.Context;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Gravity;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.view.ViewGroup;
 | 
				
			||||||
 | 
					import android.widget.FrameLayout;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
 | 
				
			||||||
 | 
					import java.util.LinkedList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RecyclerListActivity extends FragmentActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final String TAG = "RecyclerListActivity";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RecyclerView recyclerView;
 | 
				
			||||||
 | 
					    private MapViewAdapter mapViewAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_recycler_list);
 | 
				
			||||||
 | 
					        recyclerView = findViewById(R.id.rv_container);
 | 
				
			||||||
 | 
					        recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
 | 
				
			||||||
 | 
					        mapViewAdapter = new MapViewAdapter(this);
 | 
				
			||||||
 | 
					        recyclerView.setAdapter(mapViewAdapter);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        if (recyclerView != null) {
 | 
				
			||||||
 | 
					            recyclerView.setAdapter(null);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static class MapViewHolder extends RecyclerView.ViewHolder {
 | 
				
			||||||
 | 
					        MapView mMapView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public MapViewHolder(@NonNull View itemView, MapView mapView) {
 | 
				
			||||||
 | 
					            super(itemView);
 | 
				
			||||||
 | 
					            mMapView = mapView;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void onRecycle() {
 | 
				
			||||||
 | 
					            if (mMapView != null) {
 | 
				
			||||||
 | 
					                mMapView.onPause();
 | 
				
			||||||
 | 
					                mMapView.onStop();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void onBind() {
 | 
				
			||||||
 | 
					            if (mMapView != null) {
 | 
				
			||||||
 | 
					                mMapView.onResume();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static class MapViewAdapter extends RecyclerView.Adapter<MapViewHolder> {
 | 
				
			||||||
 | 
					        private List<MapView> mMapViews;
 | 
				
			||||||
 | 
					        private static final int COUNT = 15;
 | 
				
			||||||
 | 
					        private Context mContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public MapViewAdapter(Context context) {
 | 
				
			||||||
 | 
					            mContext = context.getApplicationContext();
 | 
				
			||||||
 | 
					            mMapViews = new LinkedList<>();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @NonNull
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public MapViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, final int type) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            FrameLayout mapContainer = new FrameLayout(mContext);
 | 
				
			||||||
 | 
					            if (type == 1) {
 | 
				
			||||||
 | 
					                TencentMapOptions tencentMapOptions = new TencentMapOptions();
 | 
				
			||||||
 | 
					                tencentMapOptions.setDisallowInterceptTouchEvent(true);
 | 
				
			||||||
 | 
					                MapView mapView = new MapView(mContext, tencentMapOptions);
 | 
				
			||||||
 | 
					                mapView.setId(View.NO_ID);
 | 
				
			||||||
 | 
					                mapView.setLayoutParams(new FrameLayout.LayoutParams(1000, 700));
 | 
				
			||||||
 | 
					                mapContainer.addView(mapView);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
 | 
				
			||||||
 | 
					                lp.gravity = Gravity.CENTER;
 | 
				
			||||||
 | 
					                return new MapViewHolder(mapContainer, mapView);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                return new MapViewHolder(mapContainer, null);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onBindViewHolder(@NonNull MapViewHolder mapViewHolder, int i) {
 | 
				
			||||||
 | 
					            mapViewHolder.onBind();
 | 
				
			||||||
 | 
					            if (mapViewHolder.mMapView != null) {
 | 
				
			||||||
 | 
					                mMapViews.add(mapViewHolder.mMapView);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getItemCount() {
 | 
				
			||||||
 | 
					            return COUNT;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public int getItemViewType(int position) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (position % 3 == 0) {
 | 
				
			||||||
 | 
					                return 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return super.getItemViewType(position);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onViewRecycled(@NonNull MapViewHolder holder) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            holder.onRecycle();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
 | 
				
			||||||
 | 
					            for (MapView mapView : mMapViews) {
 | 
				
			||||||
 | 
					                mapView.onDestroy();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,86 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.camera;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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)));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,126 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.circle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.circle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,80 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,82 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.gesture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,63 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,197 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
 | 
					import android.widget.Switch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlay;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.aggregation.AggregationOverlayProvider;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.aggregation.HoneyCombVectorOverlayProvider;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class AggregationOverlayActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private AggregationOverlay aggregationOverlay;
 | 
				
			||||||
 | 
					    private AggregationOverlayProvider aggregationOverlayProvider;
 | 
				
			||||||
 | 
					    private Switch btnSwitch3D;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_aggregation_overlay_design);
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        getMenuInflater().inflate(R.menu.vectorheatmap, menu);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onPrepareOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
 | 
				
			||||||
 | 
					        return super.onPrepareOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case R.id.menu_open_vectorheatmap:
 | 
				
			||||||
 | 
					                addAggregation();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.menu_close_vectorheatmap:
 | 
				
			||||||
 | 
					                mIsSelected = false;
 | 
				
			||||||
 | 
					                if (aggregationOverlay != null) {
 | 
				
			||||||
 | 
					                    aggregationOverlay.remove();
 | 
				
			||||||
 | 
					                    aggregationOverlay = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        supportInvalidateOptionsMenu();
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.setMapStyle(3);
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(10f));
 | 
				
			||||||
 | 
					        btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D);
 | 
				
			||||||
 | 
					        bindListener();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void bindListener() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
 | 
				
			||||||
 | 
					                switch (compoundButton.getId()) {
 | 
				
			||||||
 | 
					                    case R.id.btn_switch_3D:
 | 
				
			||||||
 | 
					                        if (aggregationOverlay != null) {
 | 
				
			||||||
 | 
					                            if (compoundButton.isChecked()) {
 | 
				
			||||||
 | 
					                                aggregationOverlayProvider.enable3D(true);
 | 
				
			||||||
 | 
					                                aggregationOverlayProvider.enable3D(true).setAnimateDuration(3000);
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                aggregationOverlayProvider.enable3D(false);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            mTencentMap.updateVectorOverlay(aggregationOverlay, aggregationOverlayProvider);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    default:
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected void addAggregation() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (aggregationOverlay != null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //  mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.961629, 116.355343), 12, 0, 0)));
 | 
				
			||||||
 | 
					        mTencentMap.setBuildingEnable(false);
 | 
				
			||||||
 | 
					        mTencentMap.setPoisEnabled(false);
 | 
				
			||||||
 | 
					        BufferedReader br = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            ArrayList<WeightedLatLng> nodes = new ArrayList<WeightedLatLng>();
 | 
				
			||||||
 | 
					            br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k")));
 | 
				
			||||||
 | 
					            String line = null;
 | 
				
			||||||
 | 
					            while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                String[] lines = line.split("\t");
 | 
				
			||||||
 | 
					                if (lines.length == 3) {
 | 
				
			||||||
 | 
					                    double value = Double.parseDouble(lines[2]);
 | 
				
			||||||
 | 
					                    LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0])));
 | 
				
			||||||
 | 
					                    nodes.add(new WeightedLatLng(latLng, value));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int[] colors = {
 | 
				
			||||||
 | 
					                    Color.argb(255, 0x01, 0x2C, 0x4B),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0x17, 0x3E, 0x59),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0x3A, 0x73, 0x78),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0x98, 0xCD, 0x9A),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0xF6, 0xFB, 0xB6)
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            double[] startPoints = {0.f, 0.1f, 0.15f, 0.3f, 0.5f};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            aggregationOverlayProvider = new HoneyCombVectorOverlayProvider()
 | 
				
			||||||
 | 
					                    .nodes(nodes.toArray(new WeightedLatLng[0]))
 | 
				
			||||||
 | 
					                    .setHeightRange(0, 4000);
 | 
				
			||||||
 | 
					            aggregationOverlayProvider.colors(colors, startPoints);
 | 
				
			||||||
 | 
					            aggregationOverlay = mTencentMap.addVectorOverlay(aggregationOverlayProvider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            if (br != null) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    br.close();
 | 
				
			||||||
 | 
					                } catch (IOException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,182 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
 | 
					import android.widget.Switch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.FromToLatLng;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlay;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.od.ArcLineOverlayProvider;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ArcLineLayerActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private VectorOverlay vectorOverlay;
 | 
				
			||||||
 | 
					    private ArcLineOverlayProvider options;
 | 
				
			||||||
 | 
					    private Switch btnSwitch3D;
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					    private Switch btnani3D;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_arc_line_layer_design);
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        getMenuInflater().inflate(R.menu.vectorheatmap, menu);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onPrepareOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
 | 
				
			||||||
 | 
					        return super.onPrepareOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case R.id.menu_open_vectorheatmap:
 | 
				
			||||||
 | 
					                btnSwitch3D.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					                addArcLineLayer();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.menu_close_vectorheatmap:
 | 
				
			||||||
 | 
					                mIsSelected = false;
 | 
				
			||||||
 | 
					                if (vectorOverlay != null) {
 | 
				
			||||||
 | 
					                    vectorOverlay.remove();
 | 
				
			||||||
 | 
					                    vectorOverlay = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        supportInvalidateOptionsMenu();
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f));
 | 
				
			||||||
 | 
					        btnSwitch3D = (Switch) findViewById(R.id.btn_switch_3D);
 | 
				
			||||||
 | 
					        bindListener();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void bindListener() {
 | 
				
			||||||
 | 
					        CompoundButton.OnCheckedChangeListener onCheckedChangeListener = new CompoundButton.OnCheckedChangeListener() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
 | 
				
			||||||
 | 
					                switch (compoundButton.getId()) {
 | 
				
			||||||
 | 
					                    case R.id.btn_switch_3D:
 | 
				
			||||||
 | 
					                        if (vectorOverlay != null) {
 | 
				
			||||||
 | 
					                            if (compoundButton.isChecked()) {
 | 
				
			||||||
 | 
					                                options.enable3D(true);
 | 
				
			||||||
 | 
					                            } else {
 | 
				
			||||||
 | 
					                                options.enable3D(false);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                            mTencentMap.updateVectorOverlay(vectorOverlay, options);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    default:
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        btnSwitch3D.setOnCheckedChangeListener(onCheckedChangeListener);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addArcLineLayer() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (vectorOverlay == null) {
 | 
				
			||||||
 | 
					            //  mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(39.9229731, 116.422880668), 8, 0f, 0f)));
 | 
				
			||||||
 | 
					            mTencentMap.setMapStyle(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            int color = Color.argb(255, 0, 255, 170);
 | 
				
			||||||
 | 
					            BufferedReader br = null;
 | 
				
			||||||
 | 
					            final ArrayList<FromToLatLng> nodes = new ArrayList<FromToLatLng>();
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("arc.dat")));
 | 
				
			||||||
 | 
					                String line = null;
 | 
				
			||||||
 | 
					                while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                    String[] lines = line.split(" ");
 | 
				
			||||||
 | 
					                    if (lines.length == 5) {
 | 
				
			||||||
 | 
					                        double arc = Double.parseDouble(lines[4]);
 | 
				
			||||||
 | 
					                        LatLng startLatLng = new LatLng((Double.parseDouble(lines[0])), (Double.parseDouble(lines[1])));
 | 
				
			||||||
 | 
					                        LatLng endLatLng = new LatLng((Double.parseDouble(lines[2])), (Double.parseDouble(lines[3])));
 | 
				
			||||||
 | 
					                        nodes.add(new FromToLatLng(startLatLng, endLatLng));
 | 
				
			||||||
 | 
					                        //nodes.add(new FromToLatLng(startLatLng, endLatLng, arc));
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int[] colors = {
 | 
				
			||||||
 | 
					                    Color.argb(255, 0, 0xd4, 0xff),
 | 
				
			||||||
 | 
					                    Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0, 0xd4, 0xff)
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            options = new ArcLineOverlayProvider().data(nodes).opacity(2f).width(4).gradient(colors).setAnimateDuration(3000).setHighlightDuration(200).animateColor(Color.argb(255, 0xff, 0xff, 0xff));
 | 
				
			||||||
 | 
					            vectorOverlay = mTencentMap.addVectorOverlay(options);
 | 
				
			||||||
 | 
					            mTencentMap.setPoisEnabled(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,126 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.heatmap.Gradient;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.heatmap.HeatMapTileProvider;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.heatmap.WeightedLatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.TileOverlay;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.TileOverlayOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class DrawHeatOverlayActivity extends SupportMapFragmentActivity implements HeatMapTileProvider.OnHeatMapReadyListener{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private TileOverlay mHeatmapTileOverlay;
 | 
				
			||||||
 | 
					    private HeatMapTileProvider mProvider;
 | 
				
			||||||
 | 
					    //热力图半径
 | 
				
			||||||
 | 
					    private static final int ALT_HEATMAP_RADIUS = HeatMapTileProvider.DEFAULT_RADIUS;
 | 
				
			||||||
 | 
					    //热力图透明度
 | 
				
			||||||
 | 
					    private static final double ALT_HEATMAP_OPACITY = HeatMapTileProvider.DEFAULT_OPACITY;
 | 
				
			||||||
 | 
					    //热力图渐变方案
 | 
				
			||||||
 | 
					    public static final Gradient ALT_HEATMAP_GRADIENT = HeatMapTileProvider.DEFAULT_GRADIENT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final int[] CUSTOM_GRADIENT_COLORS = {
 | 
				
			||||||
 | 
					            Color.argb(0,0, 225, 225),
 | 
				
			||||||
 | 
					            Color.rgb(102, 125, 200),
 | 
				
			||||||
 | 
					            Color.rgb(255, 0, 0)
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static final float[] CUSTOM_GRADIENT_START_POINTS = {
 | 
				
			||||||
 | 
					            0.0f, 0.2f, 1f
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static final Gradient CUSTOM_HEATMAP_GRADIENT = new Gradient(CUSTOM_GRADIENT_COLORS,
 | 
				
			||||||
 | 
					            CUSTOM_GRADIENT_START_POINTS);
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setUpMap();
 | 
				
			||||||
 | 
					        Button first = findViewById(R.id.btn_bottom);
 | 
				
			||||||
 | 
					        first.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					        first.setText("自定义热力图");
 | 
				
			||||||
 | 
					        first.setOnClickListener(new View.OnClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onClick(View v) {
 | 
				
			||||||
 | 
					                mProvider.setHeatTileGenerator(new HeatMapTileProvider.HeatTileGenerator() {
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public double[] generateKernel(int radius) {
 | 
				
			||||||
 | 
					                        double[] kernel = new double[radius * 2 + 1];
 | 
				
			||||||
 | 
					                        for (int i = -radius; i <= radius; i++) {
 | 
				
			||||||
 | 
					                            kernel[i + radius] = Math.exp(-i * i / (2 * (radius / 2f) * (radius / 2f)));
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        return kernel;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    @Override
 | 
				
			||||||
 | 
					                    public int[] generateColorMap(double opacity) {
 | 
				
			||||||
 | 
					                        return CUSTOM_HEATMAP_GRADIENT.generateColorMap(opacity);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					                mHeatmapTileOverlay.clearTileCache();
 | 
				
			||||||
 | 
					                mHeatmapTileOverlay.reload();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    private void setUpMap() {
 | 
				
			||||||
 | 
					        tencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
 | 
				
			||||||
 | 
					                new com.tencent.tencentmap.mapsdk.maps.model.LatLng(39.917128, 116.399266),
 | 
				
			||||||
 | 
					                7.946870f));
 | 
				
			||||||
 | 
					        initHeatMap();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    private void initHeatMap() {
 | 
				
			||||||
 | 
					        BufferedReader br = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            ArrayList<WeightedLatLng> nodes = new ArrayList<>();
 | 
				
			||||||
 | 
					            br = new BufferedReader(new InputStreamReader(
 | 
				
			||||||
 | 
					                    getResources().getAssets().open("data2k")));
 | 
				
			||||||
 | 
					            String line;
 | 
				
			||||||
 | 
					            while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                String[] lines = line.split("\t");
 | 
				
			||||||
 | 
					                if (lines.length == 3) {
 | 
				
			||||||
 | 
					                    double value = Double.parseDouble(lines[2]);
 | 
				
			||||||
 | 
					                    LatLng latLng = new LatLng((Double.parseDouble(lines[1])),
 | 
				
			||||||
 | 
					                            (Double.parseDouble(lines[0])));
 | 
				
			||||||
 | 
					                    nodes.add(new WeightedLatLng(latLng, value));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mProvider = new HeatMapTileProvider.Builder()
 | 
				
			||||||
 | 
					                    .weightedData(nodes)
 | 
				
			||||||
 | 
					                    .gradient(ALT_HEATMAP_GRADIENT)
 | 
				
			||||||
 | 
					                    .opacity(ALT_HEATMAP_OPACITY)
 | 
				
			||||||
 | 
					                    .radius(ALT_HEATMAP_RADIUS)
 | 
				
			||||||
 | 
					                    .readyListener(this)
 | 
				
			||||||
 | 
					                    .build(tencentMap);
 | 
				
			||||||
 | 
					            mHeatmapTileOverlay = tencentMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            if (br != null) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    br.close();
 | 
				
			||||||
 | 
					                } catch (IOException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onHeatMapReady() {
 | 
				
			||||||
 | 
					        mHeatmapTileOverlay.clearTileCache();
 | 
				
			||||||
 | 
					        mHeatmapTileOverlay.reload();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class DrawOldVersionHeatOverlayActivity extends SupportMapFragmentActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//    private HeatOverlay heatOverlay;
 | 
				
			||||||
 | 
					//    private HeatOverlay newHeatOverlay;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    @Override
 | 
				
			||||||
 | 
					//    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					//        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					//        HeatOverlayOptions options = setHeatMap(getHeatDataNodes()); //热力图选项
 | 
				
			||||||
 | 
					//        HeatOverlayOptions newOptions = setHeatMap(transferHeatNodes(getHeatDataNodes())); //新的热力图选项
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        heatOverlay = tencentMap.addHeatOverlay(options); //绘制热力图
 | 
				
			||||||
 | 
					//        heatOverlay.remove(); //移除热力图
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        newHeatOverlay = tencentMap.addHeatOverlay(newOptions); //绘制转换过坐标的热力图
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    /**
 | 
				
			||||||
 | 
					//     * 设置热力图Options
 | 
				
			||||||
 | 
					//     *
 | 
				
			||||||
 | 
					//     */
 | 
				
			||||||
 | 
					//    private HeatOverlayOptions setHeatMap(ArrayList<HeatDataNode> nodes){
 | 
				
			||||||
 | 
					//        //配置热力图参数
 | 
				
			||||||
 | 
					//        HeatOverlayOptions heatOverlayOptions = new HeatOverlayOptions();
 | 
				
			||||||
 | 
					//        heatOverlayOptions.nodes(nodes)
 | 
				
			||||||
 | 
					//                .radius(18)// 半径,单位是像素,这个数值越大运算量越大,默认值为18,建议设置在18-30之间)
 | 
				
			||||||
 | 
					//                .colorMapper(new ColorMapper())
 | 
				
			||||||
 | 
					//                .onHeatMapReadyListener(()->{
 | 
				
			||||||
 | 
					//                    runOnUiThread(()-> {
 | 
				
			||||||
 | 
					//                        Toast.makeText(getApplicationContext(),
 | 
				
			||||||
 | 
					//                                "热力图数据准备完毕", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					//                    });
 | 
				
			||||||
 | 
					//                });
 | 
				
			||||||
 | 
					//        return heatOverlayOptions;
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    /**
 | 
				
			||||||
 | 
					//     * 配色方案
 | 
				
			||||||
 | 
					//     */
 | 
				
			||||||
 | 
					//    class ColorMapper implements HeatOverlayOptions.IColorMapper {
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        @Override
 | 
				
			||||||
 | 
					//        public int colorForValue(double arg0) {
 | 
				
			||||||
 | 
					//            // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					//            int alpha, red, green, blue;
 | 
				
			||||||
 | 
					//            if (arg0 > 1) {
 | 
				
			||||||
 | 
					//                arg0 = 1;
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//            arg0 = Math.sqrt(arg0);
 | 
				
			||||||
 | 
					//            float a = 20000;
 | 
				
			||||||
 | 
					//            red = 255;
 | 
				
			||||||
 | 
					//            green = 119;
 | 
				
			||||||
 | 
					//            blue = 3;
 | 
				
			||||||
 | 
					//            if (arg0 > 0.7) {
 | 
				
			||||||
 | 
					//                green = 78;
 | 
				
			||||||
 | 
					//                blue = 1;
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//            if (arg0 > 0.6) {
 | 
				
			||||||
 | 
					//                alpha = (int) (a * Math.pow(arg0 - 0.7, 3) + 240);
 | 
				
			||||||
 | 
					//            } else if (arg0 > 0.4) {
 | 
				
			||||||
 | 
					//                alpha = (int) (a * Math.pow(arg0 - 0.5, 3) + 200);
 | 
				
			||||||
 | 
					//            } else if (arg0 > 0.2) {
 | 
				
			||||||
 | 
					//                alpha = (int) (a * Math.pow(arg0 - 0.3, 3) + 160);
 | 
				
			||||||
 | 
					//            } else {
 | 
				
			||||||
 | 
					//                alpha = (int) (700 * arg0);
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//            if (alpha > 255) {
 | 
				
			||||||
 | 
					//                alpha = 255;
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//            return Color.argb(alpha, red, green, blue);
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    /**
 | 
				
			||||||
 | 
					//     * 准备热力图数据
 | 
				
			||||||
 | 
					//     * @return
 | 
				
			||||||
 | 
					//     */
 | 
				
			||||||
 | 
					//    private ArrayList<HeatDataNode> getHeatDataNodes(){
 | 
				
			||||||
 | 
					//        //HeatDataNode 是热力图热点,包括热点位置和热度值(HeatOverlay会根据传入的全部节点的热度值范围计算最终的颜色表现)
 | 
				
			||||||
 | 
					//        ArrayList<HeatDataNode> nodes = new ArrayList<>();
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984108,116.307557), 86));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984208,116.307457), 44));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.983208,116.307457), 64));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.983208,116.317457), 54));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.684308,116.317457), 34));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.684108,116.307457), 24));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984408,116.327457), 44));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984508,116.307457), 54));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984208,116.307457), 14));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984298,116.307457), 64));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984208,116.327457), 74));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.984108,116.317457), 84));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.983208,116.297457), 65));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.982208,116.307457), 54));
 | 
				
			||||||
 | 
					//        nodes.add(new HeatDataNode(new LatLng(39.985208,116.297457), 69));
 | 
				
			||||||
 | 
					//        return nodes;
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//    private ArrayList<HeatDataNode> transferHeatNodes(ArrayList<HeatDataNode> nodes){
 | 
				
			||||||
 | 
					//        ArrayList<HeatDataNode> newNodes = new ArrayList<HeatDataNode>();
 | 
				
			||||||
 | 
					//        for (HeatDataNode node: nodes){
 | 
				
			||||||
 | 
					//            newNodes.add(new HeatDataNode(new LatLng(node.getPoint().getLatitude() + 0.01, node.getPoint().getLongitude() - 0.01), Math.floor(node.getValue() + Math.random())));
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//        }
 | 
				
			||||||
 | 
					//        return newNodes;
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,166 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.AdapterView;
 | 
				
			||||||
 | 
					import android.widget.ArrayAdapter;
 | 
				
			||||||
 | 
					import android.widget.Spinner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlay;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMapOptions;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.GeneralTranslateAnimator;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.IAnimatorModel;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.GeoGraphicType;
 | 
				
			||||||
 | 
					import static com.tencent.map.sdk.utilities.visualization.glmodel.GLModelOverlayProvider.CoordType.PixelType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class GLModelActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 和其他覆盖物相同三维模型图也可控制图层的Level和zIndex
 | 
				
			||||||
 | 
					     * 可通过 GLModelOverlayProvider的displayLevel和zIndex进行设置
 | 
				
			||||||
 | 
					     * displayLevel - 默认层级为POI之下 OverlayLevel.OverlayLevelAboveBuildings
 | 
				
			||||||
 | 
					     * 相同Level内的显示层级关系通过zIndex(int)来控制,zIndex越大越靠上显示。 Level优先级高于zIndex displayLevel必须为如下值之一,否则不生效
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private MapView mapView;
 | 
				
			||||||
 | 
					    protected TencentMap tencentMap;
 | 
				
			||||||
 | 
					    private String mResourcePath;
 | 
				
			||||||
 | 
					    private GLModelOverlay vectorOverlay;
 | 
				
			||||||
 | 
					    private final String mLine = "39.98409,116.30804,39.98409,116.3081,39.98409,116.3081,39.98397,116.30809,39.9823,116.30809,39.9811,116.30817,39.9811,116.30817,39.97918,116.308266,39.97918,116.308266,39.9791,116.30827,39.9791,116.30827,39.979008,116.3083,39.978756,116.3084,39.978386,116.3086,39.977867,116.30884,39.977547,116.308914,39.976845,116.308914,39.975826,116.308945,39.975826,116.308945,39.975666,116.30901,39.975716,116.310486,39.975716,116.310486,39.975754,116.31129,39.975754,116.31129,39.975784,116.31241,39.975822,116.31327,39.97581,116.31352,39.97588,116.31591,39.97588,116.31591,39.97591,116.31735,39.97591,116.31735,39.97593,116.31815,39.975967,116.31879,39.975986,116.32034,39.976055,116.32211,39.976086,116.323395,39.976105,116.32514,39.976173,116.32631,39.976254,116.32811,39.976265,116.3288,39.976345,116.33123,39.976357,116.33198,39.976418,116.33346,39.976418,116.33346,39.97653,116.333755,39.97653,116.333755,39.978157,116.333664,39.978157,116.333664,39.978195,116.33509,39.978195,116.33509,39.978226,116.33625,39.978226,116.33625,39.97823,116.33656,39.97823,116.33656,39.978256,116.33791,39.978256,116.33791,39.978016,116.33789,39.977047,116.33791,39.977047,116.33791,39.97706,116.33768,39.97706,116.33768,39.976967,116.33706,39.976967,116.33697";
 | 
				
			||||||
 | 
					    private LatLng[] mCarLatLngArray;
 | 
				
			||||||
 | 
					    private GeneralTranslateAnimator animator;
 | 
				
			||||||
 | 
					    private Polyline polyline;
 | 
				
			||||||
 | 
					    private Spinner mSpinner;
 | 
				
			||||||
 | 
					    private String[] glmodelAnimator = new String[]{"开启平滑移动", "开启骨骼动画", "关闭骨骼动画"};
 | 
				
			||||||
 | 
					    private GLModelOverlayProvider provider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_g_l_model);
 | 
				
			||||||
 | 
					        mapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        tencentMap = this.mapView.getMap();
 | 
				
			||||||
 | 
					        String[] linePointsStr = mLine.split(",");
 | 
				
			||||||
 | 
					        mCarLatLngArray = new LatLng[linePointsStr.length / 4];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = 0; i < mCarLatLngArray.length; i++) {
 | 
				
			||||||
 | 
					            double latitude = Double.parseDouble(linePointsStr[i * 4]);
 | 
				
			||||||
 | 
					            double longitude = Double.parseDouble(linePointsStr[i * 4 + 1]);
 | 
				
			||||||
 | 
					            mCarLatLngArray[i] = new LatLng(latitude, longitude);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        polyline = tencentMap.addPolyline(new PolylineOptions().add(mCarLatLngArray).color(R.color.colorAccent).arrow(true));
 | 
				
			||||||
 | 
					        tencentMap.animateCamera(CameraUpdateFactory.newLatLngBounds(LatLngBounds.builder().include(Arrays.asList(mCarLatLngArray)).build(), 50));
 | 
				
			||||||
 | 
					        creatglmode();
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void creatglmode() {
 | 
				
			||||||
 | 
					        //gltf格式三维模型文件在assets内
 | 
				
			||||||
 | 
					        String file = "BrainStem.gltf";
 | 
				
			||||||
 | 
					        String SKELETON_PATH = "gltf-BrainStem";
 | 
				
			||||||
 | 
					        //获取外部存储
 | 
				
			||||||
 | 
					        mResourcePath = getExternalFilesDir(null).getAbsolutePath() + File.separator + SKELETON_PATH;
 | 
				
			||||||
 | 
					        provider = new GLModelOverlayProvider(
 | 
				
			||||||
 | 
					                mResourcePath + File.separator + file,
 | 
				
			||||||
 | 
					                new LatLng(39.98409, 116.30804)).coordType(PixelType)
 | 
				
			||||||
 | 
					                .pixelBounds(400, 1200).rotationX(90).rotationY(0).rotationZ(0).setClickEnable(true);
 | 
				
			||||||
 | 
					        vectorOverlay = tencentMap.addVectorOverlay(provider);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mSpinner = findViewById(R.id.sp_glmode);
 | 
				
			||||||
 | 
					        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, glmodelAnimator);
 | 
				
			||||||
 | 
					        mSpinner.setAdapter(adapter);
 | 
				
			||||||
 | 
					        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
 | 
				
			||||||
 | 
					                switch (position) {
 | 
				
			||||||
 | 
					                    //开启骨骼动画
 | 
				
			||||||
 | 
					                    case 0:
 | 
				
			||||||
 | 
					                        animator = new GeneralTranslateAnimator.Builder(vectorOverlay, 6000,
 | 
				
			||||||
 | 
					                                mCarLatLngArray).rotateEnabled(true).initRotate(180).modelType(GeneralTranslateAnimator.ModelType.MODEL_OVERLAY).build();
 | 
				
			||||||
 | 
					                        animator.startAnimation();
 | 
				
			||||||
 | 
					                        animator.addAnimatorEndListener(new IAnimatorModel.IAnimatorEndListener() {
 | 
				
			||||||
 | 
					                            @Override
 | 
				
			||||||
 | 
					                            public void onAnimatorEnd() {
 | 
				
			||||||
 | 
					                                Log.i("TransformActivity", "onAnimatorEnd");
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    //停止骨骼动画
 | 
				
			||||||
 | 
					                    case 1:
 | 
				
			||||||
 | 
					                        vectorOverlay.playSkeletonAnimation(0, 1, true);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    //模型平移
 | 
				
			||||||
 | 
					                    case 2:
 | 
				
			||||||
 | 
					                        vectorOverlay.stopSkeletonAnimation();
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onNothingSelected(AdapterView<?> parent) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * mapview的生命周期管理
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mapView.onDestroy();
 | 
				
			||||||
 | 
					        vectorOverlay.remove();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onRestart() {
 | 
				
			||||||
 | 
					        super.onRestart();
 | 
				
			||||||
 | 
					        mapView.onRestart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,171 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.WeightedLatLng;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlay;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.heatmap.GradientVectorOverlayProvider;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class HeatMapVectorOverlayActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private GradientVectorOverlay heatTileOverlay;
 | 
				
			||||||
 | 
					    private GradientVectorOverlayProvider heatMapTileProvider;
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_heat_map_vector_overlay_design);
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        getMenuInflater().inflate(R.menu.vectorheatmap, menu);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onPrepareOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
 | 
				
			||||||
 | 
					        return super.onPrepareOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case R.id.menu_open_vectorheatmap:
 | 
				
			||||||
 | 
					                addHeatMap();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.menu_close_vectorheatmap:
 | 
				
			||||||
 | 
					                mIsSelected = false;
 | 
				
			||||||
 | 
					                if (heatTileOverlay != null) {
 | 
				
			||||||
 | 
					                    heatTileOverlay.remove();
 | 
				
			||||||
 | 
					                    heatTileOverlay = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        supportInvalidateOptionsMenu();
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.setMapStyle(3);
 | 
				
			||||||
 | 
					        CameraUpdate cameraSigma =
 | 
				
			||||||
 | 
					                CameraUpdateFactory.newCameraPosition(new CameraPosition(
 | 
				
			||||||
 | 
					                        new LatLng(31.085414, 111.024319),
 | 
				
			||||||
 | 
					                        4,
 | 
				
			||||||
 | 
					                        20f,
 | 
				
			||||||
 | 
					                        1f));
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(cameraSigma);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addHeatMap() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (heatTileOverlay != null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        mTencentMap.setBuildingEnable(false);
 | 
				
			||||||
 | 
					        mTencentMap.setPoisEnabled(false);
 | 
				
			||||||
 | 
					        BufferedReader br = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            ArrayList<WeightedLatLng> nodes = new ArrayList<WeightedLatLng>();
 | 
				
			||||||
 | 
					            br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("data2k")));
 | 
				
			||||||
 | 
					            String line = null;
 | 
				
			||||||
 | 
					            while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                String[] lines = line.split("\t");
 | 
				
			||||||
 | 
					                if (lines.length == 3) {
 | 
				
			||||||
 | 
					                    double value = Double.parseDouble(lines[2]);
 | 
				
			||||||
 | 
					                    LatLng latLng = new LatLng((Double.parseDouble(lines[1])), (Double.parseDouble(lines[0])));
 | 
				
			||||||
 | 
					                    nodes.add(new WeightedLatLng(latLng, value));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // 通用配色1
 | 
				
			||||||
 | 
					            int[] colors = {
 | 
				
			||||||
 | 
					                    Color.argb(255, 77, 111, 255),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0, 238, 227),
 | 
				
			||||||
 | 
					                    Color.argb(255, 113, 236, 80),
 | 
				
			||||||
 | 
					                    Color.argb(255, 255, 176, 0),
 | 
				
			||||||
 | 
					                    Color.argb(255, 255, 72, 0)
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            float[] startPoints = {0.1f, 0.185f, 0.3571f, 0.6142f, 1f};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            heatMapTileProvider = new GradientVectorOverlayProvider()
 | 
				
			||||||
 | 
					                    .weightedData(nodes).enable3D(true)
 | 
				
			||||||
 | 
					                    .radius(56).setMaxHeight(500).setAnimateDuration(3000);
 | 
				
			||||||
 | 
					            heatMapTileProvider.opacity(0.95f);
 | 
				
			||||||
 | 
					            heatMapTileProvider.gradient(colors, startPoints);
 | 
				
			||||||
 | 
					            heatTileOverlay = mTencentMap.addVectorOverlay(heatMapTileProvider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            if (br != null) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    br.close();
 | 
				
			||||||
 | 
					                } catch (IOException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,180 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.AdapterView;
 | 
				
			||||||
 | 
					import android.widget.ArrayAdapter;
 | 
				
			||||||
 | 
					import android.widget.CompoundButton;
 | 
				
			||||||
 | 
					import android.widget.Spinner;
 | 
				
			||||||
 | 
					import android.widget.Switch;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.ScatterLatLng;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.scatterplot.BitmapScatterPlotOverlayProvider;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.scatterplot.DotScatterPlotOverlayProvider;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Random;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ScatterPlotOverlayActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private VectorOverlay vectorOverlay;
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					    private DotScatterPlotOverlayProvider dotScatterPlotOverlayProvider;
 | 
				
			||||||
 | 
					    private BitmapScatterPlotOverlayProvider provider;
 | 
				
			||||||
 | 
					    private String[] styles = new String[]{"添加点散点", "添加图片散点"};
 | 
				
			||||||
 | 
					    private Spinner mSpinner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_scatter_plot_overlay);
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.zoomTo(5f));
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(40.040219, 116.273348), 20, 0, 0)));
 | 
				
			||||||
 | 
					        mSpinner = findViewById(R.id.sp_style);
 | 
				
			||||||
 | 
					        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, styles);
 | 
				
			||||||
 | 
					        mSpinner.setAdapter(adapter);
 | 
				
			||||||
 | 
					        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
 | 
				
			||||||
 | 
					                switch (position) {
 | 
				
			||||||
 | 
					                    case 0:
 | 
				
			||||||
 | 
					                        if (vectorOverlay != null) {
 | 
				
			||||||
 | 
					                            vectorOverlay.remove();
 | 
				
			||||||
 | 
					                            vectorOverlay = null;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        addDotVectorOverlay();
 | 
				
			||||||
 | 
					                        mTencentMap.updateVectorOverlay(vectorOverlay, dotScatterPlotOverlayProvider);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case 1:
 | 
				
			||||||
 | 
					                        if (vectorOverlay != null) {
 | 
				
			||||||
 | 
					                            vectorOverlay.remove();
 | 
				
			||||||
 | 
					                            vectorOverlay = null;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        addBitmapVectorOverlay();
 | 
				
			||||||
 | 
					                        mTencentMap.updateVectorOverlay(vectorOverlay, provider);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onNothingSelected(AdapterView<?> parent) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addDotVectorOverlay() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (vectorOverlay == null) {
 | 
				
			||||||
 | 
					            BufferedReader br = null;
 | 
				
			||||||
 | 
					            final ArrayList<ScatterLatLng> nodes = new ArrayList<ScatterLatLng>();
 | 
				
			||||||
 | 
					            double lat = 40.040219;
 | 
				
			||||||
 | 
					            double lng = 116.273348;
 | 
				
			||||||
 | 
					            double value = 100;
 | 
				
			||||||
 | 
					            Random r = new Random();
 | 
				
			||||||
 | 
					            for (int i = 0; i < 2000; i++) {
 | 
				
			||||||
 | 
					                double a = r.nextInt(10) * 1E-5;
 | 
				
			||||||
 | 
					                double b = r.nextInt(10) * 1E-5;
 | 
				
			||||||
 | 
					                LatLng latLng = new LatLng(lat + a, lng + b);
 | 
				
			||||||
 | 
					                nodes.add(new ScatterLatLng(latLng, value));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int[] colors = {
 | 
				
			||||||
 | 
					                    Color.argb(255, 0, 0xd4, 0xff),
 | 
				
			||||||
 | 
					                    Color.argb((int) (255 * 0.3), 0, 0xd4, 0xff),
 | 
				
			||||||
 | 
					                    Color.argb(255, 0, 0xd4, 0xff)
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            dotScatterPlotOverlayProvider = new DotScatterPlotOverlayProvider().data(nodes).opacity(2f).radius(2).animate(true).colors(colors);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            vectorOverlay = mTencentMap.addVectorOverlay(dotScatterPlotOverlayProvider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addBitmapVectorOverlay() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (vectorOverlay == null) {
 | 
				
			||||||
 | 
					            final ArrayList<ScatterLatLng> nodes = new ArrayList<ScatterLatLng>();
 | 
				
			||||||
 | 
					            double lat = 40.040219;
 | 
				
			||||||
 | 
					            double lng = 116.273348;
 | 
				
			||||||
 | 
					            double value = 10;
 | 
				
			||||||
 | 
					            Random r = new Random();
 | 
				
			||||||
 | 
					            for (int i = 0; i < 1000; i++) {
 | 
				
			||||||
 | 
					                double a = r.nextInt(10) * 1E-5;
 | 
				
			||||||
 | 
					                double b = r.nextInt(10) * 1E-5;
 | 
				
			||||||
 | 
					                LatLng latLng = new LatLng(lat + a, lng + b);
 | 
				
			||||||
 | 
					                nodes.add(new ScatterLatLng(latLng, value));
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            BitmapDescriptor[] bitmaps = {
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("21.jpg"),
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("22.jpg"),
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("23.jpg"),
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("24.jpg"),
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("25.jpg"),
 | 
				
			||||||
 | 
					                    BitmapDescriptorFactory.fromAsset("26.jpg"),
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            provider = new BitmapScatterPlotOverlayProvider().data(nodes).bitmaps(bitmaps).opacity(2f).scale(20, 10);
 | 
				
			||||||
 | 
					            vectorOverlay = mTencentMap.addVectorOverlay(provider);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,147 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.heatoverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.NonNull;
 | 
				
			||||||
 | 
					import androidx.appcompat.app.AppCompatActivity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.TimeLatLng;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.datamodels.TrailLatLng;
 | 
				
			||||||
 | 
					import com.tencent.map.sdk.utilities.visualization.trails.TrailOverlayProvider;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorOverlay;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TrailOverlayActivity extends AppCompatActivity {
 | 
				
			||||||
 | 
					    private MapView mMapView;
 | 
				
			||||||
 | 
					    private TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    private VectorOverlay vectorOverlay;
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					    private TrailOverlayProvider trailOverlayProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_trail_overlay);
 | 
				
			||||||
 | 
					        init();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        getMenuInflater().inflate(R.menu.vectorheatmap, menu);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onPrepareOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
 | 
				
			||||||
 | 
					        return super.onPrepareOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case R.id.menu_open_vectorheatmap:
 | 
				
			||||||
 | 
					                addArcLineLayer();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.menu_close_vectorheatmap:
 | 
				
			||||||
 | 
					                mIsSelected = false;
 | 
				
			||||||
 | 
					                if (vectorOverlay != null) {
 | 
				
			||||||
 | 
					                    vectorOverlay.remove();
 | 
				
			||||||
 | 
					                    vectorOverlay = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        supportInvalidateOptionsMenu();
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        mMapView.onResume();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mMapView.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        mMapView.onDestroy();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStart() {
 | 
				
			||||||
 | 
					        super.onStart();
 | 
				
			||||||
 | 
					        mMapView.onStart();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        mMapView.onStop();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void init() {
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.mapView);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.942117, 116.33668), 11));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addArcLineLayer() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (vectorOverlay == null) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            mTencentMap.setPoisEnabled(false);
 | 
				
			||||||
 | 
					            BufferedReader br = null;
 | 
				
			||||||
 | 
					            long currentTime = System.currentTimeMillis();
 | 
				
			||||||
 | 
					            List<TrailLatLng> startLats = new ArrayList<>();
 | 
				
			||||||
 | 
					            try {
 | 
				
			||||||
 | 
					                br = new BufferedReader(new InputStreamReader(getResources().getAssets().open("trailData.dat")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                String line = null;
 | 
				
			||||||
 | 
					                while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                    String[] oneDot = line.split(",");
 | 
				
			||||||
 | 
					                    TimeLatLng[] timeLatLngs = new TimeLatLng[oneDot.length];
 | 
				
			||||||
 | 
					                    int i = 0;
 | 
				
			||||||
 | 
					                    for (String timeLatLng : oneDot) {
 | 
				
			||||||
 | 
					                        String[] values = timeLatLng.split("\t");
 | 
				
			||||||
 | 
					                        LatLng latlng = new LatLng((Double.parseDouble(values[0])), (Double.parseDouble(values[1])));
 | 
				
			||||||
 | 
					                        int timeStamp = Integer.parseInt(values[2]);
 | 
				
			||||||
 | 
					                        timeLatLngs[i++] = new TimeLatLng(latlng, timeStamp);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    TrailLatLng tmp = new TrailLatLng(timeLatLngs);
 | 
				
			||||||
 | 
					                    startLats.add(tmp);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (Exception e) {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            int[] colors = {Color.argb(0xff, 0x00, 0x00, 0xff),
 | 
				
			||||||
 | 
					                    Color.argb(0x00, 0xff, 0xff, 0x00)};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            trailOverlayProvider = new TrailOverlayProvider().type(TrailOverlayProvider.TrailOverlayType.Trail).data(startLats).opacity(2f).width(10).gradient(colors).setHighlightDuration(8000).setAnimateStartTime(0, 25000);
 | 
				
			||||||
 | 
					            vectorOverlay = mTencentMap.addVectorOverlay(trailOverlayProvider);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,182 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.MapView;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatAggregationUnit;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlay;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VectorHeatOverlayOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.BufferedReader;
 | 
				
			||||||
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.io.InputStreamReader;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 蜂窝热力图
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class VectorHeatMapActivity extends SupportMapFragmentActivity {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MapView mMapView;
 | 
				
			||||||
 | 
					    TencentMap mTencentMap;
 | 
				
			||||||
 | 
					    VectorHeatOverlay mOverlay;
 | 
				
			||||||
 | 
					    boolean mIsSelected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        setContentView(R.layout.activity_vector_heat_map);
 | 
				
			||||||
 | 
					        mMapView = findViewById(R.id.map_view);
 | 
				
			||||||
 | 
					        mTencentMap = mMapView.getMap();
 | 
				
			||||||
 | 
					        mTencentMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
 | 
				
			||||||
 | 
					                new LatLng(36.139985, 120.402243),
 | 
				
			||||||
 | 
					                11));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mTencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onMapClick(LatLng latlng) {
 | 
				
			||||||
 | 
					                if (mOverlay == null) {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                VectorHeatAggregationUnit unit = mOverlay.getUnit(latlng);
 | 
				
			||||||
 | 
					                if (unit == null) {
 | 
				
			||||||
 | 
					                    Log.e("VectorHeatMapActivity", "no unit found");
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                Log.e("VectorHeatMapActivity", "unit center:" + unit.getCenter() +
 | 
				
			||||||
 | 
					                        ", intensity:" + unit.getIntensity() +
 | 
				
			||||||
 | 
					                        ", size:" + unit.getNodes().length);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        getMenuInflater().inflate(R.menu.vectorheatmap, menu);
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onPrepareOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_open_vectorheatmap).setVisible(!mIsSelected);
 | 
				
			||||||
 | 
					        menu.findItem(R.id.menu_close_vectorheatmap).setVisible(mIsSelected);
 | 
				
			||||||
 | 
					        return super.onPrepareOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case R.id.menu_open_vectorheatmap:
 | 
				
			||||||
 | 
					                addVectorHeatMap();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.menu_close_vectorheatmap:
 | 
				
			||||||
 | 
					                removeVectorHeatMap();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        supportInvalidateOptionsMenu();
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ArrayList<WeightedLatLng> getHeatNodes() {
 | 
				
			||||||
 | 
					        BufferedReader br = null;
 | 
				
			||||||
 | 
					        ArrayList<WeightedLatLng> nodes = null;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            nodes = new ArrayList<>();
 | 
				
			||||||
 | 
					            br = new BufferedReader(new InputStreamReader(
 | 
				
			||||||
 | 
					                    getResources().getAssets().open("honeycomb.txt")));
 | 
				
			||||||
 | 
					            String line;
 | 
				
			||||||
 | 
					            while ((line = br.readLine()) != null) {
 | 
				
			||||||
 | 
					                String[] lines = line.split("\t");
 | 
				
			||||||
 | 
					                if (lines.length == 3) {
 | 
				
			||||||
 | 
					                    double value = Double.parseDouble(lines[2]);
 | 
				
			||||||
 | 
					                    LatLng latLng = new LatLng((Double.parseDouble(lines[1])),
 | 
				
			||||||
 | 
					                            (Double.parseDouble(lines[0])));
 | 
				
			||||||
 | 
					                    nodes.add(new WeightedLatLng(latLng, 1));
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            e.printStackTrace();
 | 
				
			||||||
 | 
					        } finally {
 | 
				
			||||||
 | 
					            if (br != null) {
 | 
				
			||||||
 | 
					                try {
 | 
				
			||||||
 | 
					                    br.close();
 | 
				
			||||||
 | 
					                } catch (IOException e) {
 | 
				
			||||||
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return nodes;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onResume() {
 | 
				
			||||||
 | 
					        super.onResume();
 | 
				
			||||||
 | 
					        if (mMapView != null) {
 | 
				
			||||||
 | 
					            mMapView.onResume();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        if (mMapView != null) {
 | 
				
			||||||
 | 
					            mMapView.onPause();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onStop() {
 | 
				
			||||||
 | 
					        super.onStop();
 | 
				
			||||||
 | 
					        if (mMapView != null) {
 | 
				
			||||||
 | 
					            mMapView.onStop();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onDestroy() {
 | 
				
			||||||
 | 
					        super.onDestroy();
 | 
				
			||||||
 | 
					        if (mMapView != null) {
 | 
				
			||||||
 | 
					            mMapView.onDestroy();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void addVectorHeatMap() {
 | 
				
			||||||
 | 
					        mIsSelected = true;
 | 
				
			||||||
 | 
					        if (mOverlay != null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        WeightedLatLng[] nodes = getHeatNodes().toArray(new WeightedLatLng[0]);
 | 
				
			||||||
 | 
					        VectorHeatOverlayOptions options = new VectorHeatOverlayOptions()
 | 
				
			||||||
 | 
					                .nodes(nodes)
 | 
				
			||||||
 | 
					                .size(2000)
 | 
				
			||||||
 | 
					                .gap(100)
 | 
				
			||||||
 | 
					                .colors(new int[]{0x45fa4b14, 0x99fa4b14, 0xd9fa4b14})
 | 
				
			||||||
 | 
					                .startPoints(new double[]{0, 0.6, 0.8});
 | 
				
			||||||
 | 
					        mOverlay = mTencentMap.addVectorHeatOverlay(options);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void removeVectorHeatMap() {
 | 
				
			||||||
 | 
					        mIsSelected = false;
 | 
				
			||||||
 | 
					        if (mOverlay == null) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        mOverlay.remove();
 | 
				
			||||||
 | 
					        mOverlay = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,251 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.google.gson.Gson;
 | 
				
			||||||
 | 
					import com.tencent.map.geolocation.TencentLocation;
 | 
				
			||||||
 | 
					import com.tencent.map.geolocation.TencentLocationListener;
 | 
				
			||||||
 | 
					import com.tencent.map.geolocation.TencentLocationManager;
 | 
				
			||||||
 | 
					import com.tencent.map.geolocation.TencentLocationRequest;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.LocationSource;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import pub.devrel.easypermissions.EasyPermissions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class LocationLayerActivity extends SupportMapFragmentActivity implements EasyPermissions.PermissionCallbacks, LocationSource, TencentLocationListener, TencentMap.OnMapLongClickListener, RadioGroup.OnCheckedChangeListener {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private OnLocationChangedListener locationChangedListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private TencentLocationManager locationManager;
 | 
				
			||||||
 | 
					    private TencentLocationRequest locationRequest;
 | 
				
			||||||
 | 
					    private MyLocationStyle locationStyle;
 | 
				
			||||||
 | 
					    private RadioGroup radioGroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //定位需要申请的权限
 | 
				
			||||||
 | 
					        String[] perms = {
 | 
				
			||||||
 | 
					                Manifest.permission.ACCESS_FINE_LOCATION,
 | 
				
			||||||
 | 
					                Manifest.permission.ACCESS_COARSE_LOCATION,
 | 
				
			||||||
 | 
					                Manifest.permission.READ_PHONE_STATE
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (EasyPermissions.hasPermissions(this, perms)) {//检查是否获取该权限
 | 
				
			||||||
 | 
					            Log.i("location", "已获取权限");
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            EasyPermissions.requestPermissions(this, "必要的权限", 0, perms);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        //设置显示定位的图标
 | 
				
			||||||
 | 
					        mapUiSettings.setMyLocationButtonEnabled(true);
 | 
				
			||||||
 | 
					        tencentMap.setOnMapLongClickListener(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        radioGroup = findViewById(R.id.location_type);
 | 
				
			||||||
 | 
					        radioGroup.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					        radioGroup.setOnCheckedChangeListener(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //建立定位
 | 
				
			||||||
 | 
					        initLocation();
 | 
				
			||||||
 | 
					        //SDK版本4.3.5新增内置定位标点击回调监听
 | 
				
			||||||
 | 
					        tencentMap.setMyLocationClickListener(new TencentMap.OnMyLocationClickListener() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public boolean onMyLocationClicked(LatLng latLng) {
 | 
				
			||||||
 | 
					                Toast.makeText(LocationLayerActivity.this, "内置定位标点击回调", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 定位的一些初始化设置
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void initLocation() {
 | 
				
			||||||
 | 
					        //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
 | 
				
			||||||
 | 
					        locationManager = TencentLocationManager.getInstance(this);
 | 
				
			||||||
 | 
					        //设置坐标系
 | 
				
			||||||
 | 
					        locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02);
 | 
				
			||||||
 | 
					        //创建定位请求
 | 
				
			||||||
 | 
					        locationRequest = TencentLocationRequest.create();
 | 
				
			||||||
 | 
					        //设置定位周期(位置监听器回调周期)为3s
 | 
				
			||||||
 | 
					        locationRequest.setInterval(3000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //地图上设置定位数据源
 | 
				
			||||||
 | 
					        tencentMap.setLocationSource(this);
 | 
				
			||||||
 | 
					        //设置当前位置可见
 | 
				
			||||||
 | 
					        tencentMap.setMyLocationEnabled(true);
 | 
				
			||||||
 | 
					        //设置定位图标样式
 | 
				
			||||||
 | 
					        setLocMarkerStyle();
 | 
				
			||||||
 | 
					        tencentMap.setMyLocationStyle(locationStyle);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 设置定位图标样式
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private void setLocMarkerStyle() {
 | 
				
			||||||
 | 
					        locationStyle = new MyLocationStyle();
 | 
				
			||||||
 | 
					        //创建图标
 | 
				
			||||||
 | 
					        BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location_icon));
 | 
				
			||||||
 | 
					        locationStyle.icon(bitmapDescriptor);
 | 
				
			||||||
 | 
					        //设置定位圆形区域的边框宽度
 | 
				
			||||||
 | 
					        locationStyle.strokeWidth(3);
 | 
				
			||||||
 | 
					        //设置圆区域的颜色
 | 
				
			||||||
 | 
					        locationStyle.fillColor(R.color.style);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Bitmap getBitMap(int resourceId) {
 | 
				
			||||||
 | 
					        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
 | 
				
			||||||
 | 
					        int width = bitmap.getWidth();
 | 
				
			||||||
 | 
					        int height = bitmap.getHeight();
 | 
				
			||||||
 | 
					        int newWidth = 55;
 | 
				
			||||||
 | 
					        int newHeight = 55;
 | 
				
			||||||
 | 
					        float widthScale = ((float) newWidth) / width;
 | 
				
			||||||
 | 
					        float heightScale = ((float) newHeight) / height;
 | 
				
			||||||
 | 
					        Matrix matrix = new Matrix();
 | 
				
			||||||
 | 
					        matrix.postScale(widthScale, heightScale);
 | 
				
			||||||
 | 
					        bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
 | 
				
			||||||
 | 
					        return bitmap;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 实现位置监听
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param tencentLocation
 | 
				
			||||||
 | 
					     * @param i
 | 
				
			||||||
 | 
					     * @param s
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (i == TencentLocation.ERROR_OK && locationChangedListener != null) {
 | 
				
			||||||
 | 
					            Location location = new Location(tencentLocation.getProvider());
 | 
				
			||||||
 | 
					            //设置经纬度以及精度
 | 
				
			||||||
 | 
					            location.setLatitude(tencentLocation.getLatitude());
 | 
				
			||||||
 | 
					            location.setLongitude(tencentLocation.getLongitude());
 | 
				
			||||||
 | 
					            location.setAccuracy(tencentLocation.getAccuracy());
 | 
				
			||||||
 | 
					            locationChangedListener.onLocationChanged(location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            //显示回调的实时位置信息
 | 
				
			||||||
 | 
					            runOnUiThread(new Runnable() {
 | 
				
			||||||
 | 
					                @Override
 | 
				
			||||||
 | 
					                public void run() {
 | 
				
			||||||
 | 
					                    //打印tencentLocation的json字符串
 | 
				
			||||||
 | 
					//                    Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onStatusUpdate(String s, int i, String s1) {
 | 
				
			||||||
 | 
					        //GPS, WiFi, Radio 等状态发生变化
 | 
				
			||||||
 | 
					        Log.v("State changed", s + "===" + s1);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void activate(OnLocationChangedListener onLocationChangedListener) {
 | 
				
			||||||
 | 
					        locationChangedListener = onLocationChangedListener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper());
 | 
				
			||||||
 | 
					        switch (err) {
 | 
				
			||||||
 | 
					            case 1:
 | 
				
			||||||
 | 
					                Toast.makeText(this, "设备缺少使用腾讯定位服务需要的基本条件", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 2:
 | 
				
			||||||
 | 
					                Toast.makeText(this, "manifest 中配置的 key 不正确", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 3:
 | 
				
			||||||
 | 
					                Toast.makeText(this, "自动加载libtencentloc.so失败", Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void deactivate() {
 | 
				
			||||||
 | 
					        locationManager.removeUpdates(this);
 | 
				
			||||||
 | 
					        locationManager = null;
 | 
				
			||||||
 | 
					        locationRequest = null;
 | 
				
			||||||
 | 
					        locationChangedListener = null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
 | 
				
			||||||
 | 
					        Log.e("location quest: ", "success");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
 | 
				
			||||||
 | 
					        Log.e("location quest: ", "failed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onMapLongClick(LatLng latLng) {
 | 
				
			||||||
 | 
					        Location location = new Location("LongPressLocationProvider");
 | 
				
			||||||
 | 
					        location.setLatitude(latLng.latitude);
 | 
				
			||||||
 | 
					        location.setLongitude(latLng.longitude);
 | 
				
			||||||
 | 
					        location.setAccuracy(20);
 | 
				
			||||||
 | 
					        locationChangedListener.onLocationChanged(location);
 | 
				
			||||||
 | 
					        Log.i("long click", new Gson().toJson(latLng));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onCheckedChanged(RadioGroup radioGroup, int i) {
 | 
				
			||||||
 | 
					        switch (i) {
 | 
				
			||||||
 | 
					            //连续定位,但不会移动到地图中心点,并且会跟随设备移动
 | 
				
			||||||
 | 
					            case R.id.btn_follow_no_center:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                initLocation();
 | 
				
			||||||
 | 
					                locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER);
 | 
				
			||||||
 | 
					                tencentMap.setMyLocationStyle(locationStyle);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            //连续定位,且将视角移动到地图中心,定位点依照设备方向旋转,并且会跟随设备移动,默认是此种类型
 | 
				
			||||||
 | 
					            case R.id.btn_location_rotate:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                initLocation();
 | 
				
			||||||
 | 
					                locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);
 | 
				
			||||||
 | 
					                tencentMap.setMyLocationStyle(locationStyle);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            //连续定位,但不会移动到地图中心点,定位点依照设备方向旋转,并且跟随设备移动
 | 
				
			||||||
 | 
					            case R.id.btn_location_rotate_no_center:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                initLocation();
 | 
				
			||||||
 | 
					                locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
 | 
				
			||||||
 | 
					                tencentMap.setMyLocationStyle(locationStyle);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            //连续定位,但不会移动到地图中心点,地图依照设备方向旋转,并且会跟随设备移动
 | 
				
			||||||
 | 
					            case R.id.btn_map_rotate_no_center:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                initLocation();
 | 
				
			||||||
 | 
					                locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER);
 | 
				
			||||||
 | 
					                tencentMap.setMyLocationStyle(locationStyle);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,190 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<String> perms) {
 | 
				
			||||||
 | 
					        Log.e("location quest: ","success");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
 | 
				
			||||||
 | 
					        Log.e("location quest: ","failed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,151 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,281 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,129 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,74 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,235 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,387 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.demo.AbsMapActivity;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<MarkerClusterItem> generalItemList = new ArrayList<>();
 | 
				
			||||||
 | 
					    private ClusterManager<MarkerClusterItem> markerClusterItemClusterManager;
 | 
				
			||||||
 | 
					    private int i = 8;
 | 
				
			||||||
 | 
					    //自定义聚合
 | 
				
			||||||
 | 
					    private ClusterManager<PetaItem> petaItemClusterManager;
 | 
				
			||||||
 | 
					    private ArrayList<PetaItem> petaItems;
 | 
				
			||||||
 | 
					    private ArrayList<LatLng> latLngs;
 | 
				
			||||||
 | 
					    private NonHierarchicalDistanceBasedAlgorithm<MarkerClusterItem> ndba;
 | 
				
			||||||
 | 
					    private DefaultClusterRenderer<MarkerClusterItem> 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<PetaItem>() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public boolean onClusterClick(Cluster<PetaItem> cluster) {
 | 
				
			||||||
 | 
					                Collection<PetaItem> 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<MarkerClusterItem> getGeneralCoords() {
 | 
				
			||||||
 | 
					        if (generalItemList == null || generalItemList.size() == 0) {
 | 
				
			||||||
 | 
					            generalItemList = getItemWithFileName("cluster_new");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return generalItemList;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //海量聚合
 | 
				
			||||||
 | 
					    private Collection<MarkerClusterItem> getMassiveCoords() {
 | 
				
			||||||
 | 
					        if (generalItemList == null || generalItemList.size() == 0) {
 | 
				
			||||||
 | 
					            generalItemList = getItemWithFileName("datab");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return generalItemList;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<MarkerClusterItem> getItemWithFileName(String cluster_new) {
 | 
				
			||||||
 | 
					        ArrayList<MarkerClusterItem> 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<PetaItem> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        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<PetaItem> 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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,116 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,45 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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 :动画
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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); //堆叠顺序,越大优先级越高
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,107 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.marker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.polygon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.polygon;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<LatLng> transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换
 | 
				
			||||||
 | 
					        List<LatLng> 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)); //设置批量添加顶点
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,178 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,194 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.polyline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Color;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import androidx.annotation.Nullable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<Integer> 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<PolylineOptions.SegmentText> 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<LatLng> getLatlons() {
 | 
				
			||||||
 | 
					        List<LatLng> latLngs = new ArrayList<LatLng>();
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,132 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<LatLng> 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<LatLng> 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<PolylineOptions.SegmentText> 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);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,291 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<LatLng> 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<Integer> 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<LatLng> getCreatePoints() {
 | 
				
			||||||
 | 
					        List<LatLng> listPoints = new ArrayList<>();
 | 
				
			||||||
 | 
					        addLine(listPoints);
 | 
				
			||||||
 | 
					        return listPoints;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static List<LatLng> getPoints(int itemId) {
 | 
				
			||||||
 | 
					        List<LatLng> listPoints = new ArrayList<LatLng>();
 | 
				
			||||||
 | 
					        if (itemId == 0) {
 | 
				
			||||||
 | 
					            addLine1(listPoints);
 | 
				
			||||||
 | 
					        } else if (itemId == 1) {
 | 
				
			||||||
 | 
					            addLine2(listPoints);
 | 
				
			||||||
 | 
					        } else if (itemId == 2) {
 | 
				
			||||||
 | 
					            addLine(listPoints);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return listPoints;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private static void addLine(List<LatLng> 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<LatLng> 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<LatLng> 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));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,87 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.polyline;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<Integer> patternLine(int [] patterns){
 | 
				
			||||||
 | 
					        List<Integer> patternLine = new ArrayList<>();
 | 
				
			||||||
 | 
					        if (patterns == null)
 | 
				
			||||||
 | 
					            return patternLine;
 | 
				
			||||||
 | 
					        for (int i = 0; i < patterns.length; i++)
 | 
				
			||||||
 | 
					            patternLine.add(patterns[i]);
 | 
				
			||||||
 | 
					        return patternLine;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private List<LatLng> transferArrayToList(LatLng[] latLngs){ //坐标数组与List转换
 | 
				
			||||||
 | 
					        List<LatLng> 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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,101 @@
 | 
				
			|||||||
 | 
					//package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<BaseObject>() {
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//            @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);
 | 
				
			||||||
 | 
					//            }
 | 
				
			||||||
 | 
					//        });
 | 
				
			||||||
 | 
					//    }
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//}
 | 
				
			||||||
@@ -0,0 +1,174 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<LatLng> 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<Integer>) parent.getTag()).
 | 
				
			||||||
 | 
					                                get(position).intValue(), R.id.sp_city);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case R.id.sp_city:
 | 
				
			||||||
 | 
					                        getDistrict(((List<Integer>) parent.getTag()).
 | 
				
			||||||
 | 
					                                get(position).intValue(), R.id.sp_district);
 | 
				
			||||||
 | 
					                        break;
 | 
				
			||||||
 | 
					                    case R.id.sp_district:
 | 
				
			||||||
 | 
					                        getDistrict(((List<Integer>) 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<BaseObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<String> names = new ArrayList<String>();
 | 
				
			||||||
 | 
					        List<Integer> ids = new ArrayList<Integer>();
 | 
				
			||||||
 | 
					        latLngs.clear();
 | 
				
			||||||
 | 
					        final List<DistrictResultObject.DistrictResult> 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<String> adapter = new ArrayAdapter<String>(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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.search;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<DrivingResultObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void onSuccess(int i, DrivingResultObject drivingResultObject) {
 | 
				
			||||||
 | 
					                if (drivingResultObject == null) {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                for (DrivingResultObject.Route route : drivingResultObject.result.routes) {
 | 
				
			||||||
 | 
					                    List<LatLng> 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) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -0,0 +1,186 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<BaseObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<BaseObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,305 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<SearchBasicActivity> 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<BaseObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<BaseObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<SuggestionResultObject.SuggestionData> mSuggestionDatas;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public SuggestionAdapter(List<SuggestionResultObject.SuggestionData> suggestionDatas) {
 | 
				
			||||||
 | 
					            // TODO Auto-generated constructor stub
 | 
				
			||||||
 | 
					            setDatas(suggestionDatas);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public void setDatas(List<SuggestionResultObject.SuggestionData> 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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,93 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<TransitResultObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<TransitResultObject.Segment> 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", "路线结果为空");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,77 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<TruckingResultObject>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            @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<TruckingResultObject.Step> 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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,76 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.search;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.util.Log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.tencent.lbssearch.object.result.RoutePlanningObject;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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<WalkingResultObject>() {
 | 
				
			||||||
 | 
					            @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", "路线结果为空");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,251 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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<Float> skews;
 | 
				
			||||||
 | 
					    private ArrayList<Float> 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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.transaction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,61 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.transaction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.transaction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.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);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,82 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.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 cc.winboll.studio.positions.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<LatLng> 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<points.size();i++){
 | 
				
			||||||
 | 
					            MarkerOptions markerOptions = new MarkerOptions().position(points.get(i)).icon(BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.marker)));
 | 
				
			||||||
 | 
					            tencentMap.addMarker(markerOptions);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CameraPosition cameraPosition = tencentMap.calculateZoomToSpanLevel(null,points,leftpadding,rightpadding,toppadding,bottompadding);
 | 
				
			||||||
 | 
					        return cameraPosition;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Bitmap getBitMap(int resourceId){
 | 
				
			||||||
 | 
					        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
 | 
				
			||||||
 | 
					        int width = bitmap.getWidth();
 | 
				
			||||||
 | 
					        int height = bitmap.getHeight();
 | 
				
			||||||
 | 
					        int newWidth = 50;
 | 
				
			||||||
 | 
					        int newHeight = 50;
 | 
				
			||||||
 | 
					        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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.transaction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.Button;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ZoomMapActivity extends SupportMapFragmentActivity implements View.OnClickListener{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Button btn,zoomin,zoomout;
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        btn = findViewById(R.id.btn_bottom);
 | 
				
			||||||
 | 
					        zoomin = findViewById(R.id.btn_zoomin);
 | 
				
			||||||
 | 
					        zoomout = findViewById(R.id.btn_zoomout);
 | 
				
			||||||
 | 
					        btn.setOnClickListener(this);
 | 
				
			||||||
 | 
					        zoomout.setOnClickListener(this);
 | 
				
			||||||
 | 
					        zoomin.setOnClickListener(this);
 | 
				
			||||||
 | 
					        btn.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					        btn.setText("缩放至17级");
 | 
				
			||||||
 | 
					        zoomin.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					        zoomout.setVisibility(View.VISIBLE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onClick(View v) {
 | 
				
			||||||
 | 
					        switch (v.getId()){
 | 
				
			||||||
 | 
					            case R.id.btn_bottom:
 | 
				
			||||||
 | 
					                CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(17f);
 | 
				
			||||||
 | 
					                tencentMap.animateCamera(cameraUpdate);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.btn_zoomin:
 | 
				
			||||||
 | 
					                CameraUpdate cameraUpdate1 = CameraUpdateFactory.zoomIn();
 | 
				
			||||||
 | 
					                tencentMap.animateCamera(cameraUpdate1);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case R.id.btn_zoomout:
 | 
				
			||||||
 | 
					                CameraUpdate cameraUpdate2 = CameraUpdateFactory.zoomOut();
 | 
				
			||||||
 | 
					                tencentMap.animateCamera(cameraUpdate2);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.utils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Bitmap;
 | 
				
			||||||
 | 
					import android.graphics.BitmapFactory;
 | 
				
			||||||
 | 
					import android.graphics.Matrix;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BitMapActivity extends SupportMapFragmentActivity {
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					        Bitmap bitmap = getBitMap(R.drawable.marker);
 | 
				
			||||||
 | 
					        BitmapDescriptorFactory.fromBitmap(bitmap);
 | 
				
			||||||
 | 
					        BitmapDescriptorFactory.fromAsset("color_texture.png");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取resourse的bitmap
 | 
				
			||||||
 | 
					     * @param resourceId
 | 
				
			||||||
 | 
					     * @return
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,57 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.utils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.graphics.Point;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.view.View;
 | 
				
			||||||
 | 
					import android.widget.TextView;
 | 
				
			||||||
 | 
					import android.widget.Toast;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					import com.google.gson.Gson;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.Projection;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.TencentMap.OnMapLongClickListener;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
 | 
				
			||||||
 | 
					import com.tencent.tencentmap.mapsdk.maps.model.VisibleRegion;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CoordinateActivity extends SupportMapFragmentActivity implements OnMapLongClickListener, 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);
 | 
				
			||||||
 | 
					        tencentMap.setOnMapLongClickListener(this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 点击地图,显示对应点击点的屏幕坐标
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param latLng
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onMapLongClick(LatLng latLng) {
 | 
				
			||||||
 | 
					        Projection projection = tencentMap.getProjection();
 | 
				
			||||||
 | 
					        Point screen = projection.toScreenLocation(latLng);
 | 
				
			||||||
 | 
					        LatLng transferLatLng = projection.fromScreenLocation(screen);
 | 
				
			||||||
 | 
					        textView.setText("屏幕坐标:" + new Gson().toJson(screen));
 | 
				
			||||||
 | 
					        Toast.makeText(this, new Gson().toJson(transferLatLng), Toast.LENGTH_SHORT).show();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 长点击地图, 显示当前地图的坐标范围
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param latLng
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onMapClick(LatLng latLng) {
 | 
				
			||||||
 | 
					        Projection projection = tencentMap.getProjection();
 | 
				
			||||||
 | 
					        VisibleRegion region = projection.getVisibleRegion();
 | 
				
			||||||
 | 
					        textView.setText("当前地图视野的经纬度:" + new Gson().toJson(region));
 | 
				
			||||||
 | 
					        Toast.makeText(this, new Gson().toJson(region), Toast.LENGTH_LONG).show();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,135 @@
 | 
				
			|||||||
 | 
					package cc.winboll.studio.positions.demo.utils;
 | 
				
			||||||
 | 
					import android.app.Activity;
 | 
				
			||||||
 | 
					import android.graphics.Bitmap;
 | 
				
			||||||
 | 
					import android.os.Bundle;
 | 
				
			||||||
 | 
					import android.os.Handler;
 | 
				
			||||||
 | 
					import android.view.Menu;
 | 
				
			||||||
 | 
					import android.view.MenuItem;
 | 
				
			||||||
 | 
					import android.widget.ImageView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.R;
 | 
				
			||||||
 | 
					import cc.winboll.studio.positions.demo.basic.SupportMapFragmentActivity;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SnapshotActivity extends SupportMapFragmentActivity {
 | 
				
			||||||
 | 
					    public MapView mapview = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public TencentMap tencentMap = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private ImageView imgView = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public TencentMap.SnapshotReadyCallback snapshotReadyCallback = new TencentMap.SnapshotReadyCallback() {
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void onSnapshotReady(Bitmap snapshot) {
 | 
				
			||||||
 | 
					            imgView.setImageBitmap(snapshot);
 | 
				
			||||||
 | 
					            // Log.d("线程", "run: "+Thread.currentThread().getName());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Handler handScreen = new Handler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    final CameraPosition camerPosition_GUGONG = new CameraPosition.Builder()
 | 
				
			||||||
 | 
					            .target(new LatLng(39.91822, 116.397165)).zoom(14.5f).bearing(200).tilt(50).build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    final CameraPosition camerPosition_YINKE = new CameraPosition.Builder()
 | 
				
			||||||
 | 
					            .target(new LatLng(31.226407, 121.48298)).zoom(17.5f).bearing(0).tilt(25).build();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Runnable runScreenShot = new Runnable() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        @Override
 | 
				
			||||||
 | 
					        public void run() {
 | 
				
			||||||
 | 
					            // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					            tencentMap.snapshot(snapshotReadyCallback, Bitmap.Config.ARGB_8888);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // TencentMap.OnTrafficUpdateListener trafficUpdateListener = new
 | 
				
			||||||
 | 
					    // TencentMap.OnTrafficUpdateListener() {
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // @Override
 | 
				
			||||||
 | 
					    // public void onTrafficUpdate(String city) {
 | 
				
			||||||
 | 
					    // Log.e("zxy", "onTrafficUpdate(): " + city);
 | 
				
			||||||
 | 
					    // // TODO Auto-generated method stub\
 | 
				
			||||||
 | 
					    // handScreen.postDelayed(runScreenShot, 2000);
 | 
				
			||||||
 | 
					    //
 | 
				
			||||||
 | 
					    // }};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onCreate(Bundle savedInstanceState) {
 | 
				
			||||||
 | 
					        super.onCreate(savedInstanceState);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        setContentView(R.layout.screenshot);
 | 
				
			||||||
 | 
					        mapview = (MapView) findViewById(R.id.map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        tencentMap = mapview.getMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // tencentMap.setOnTrafficUpdate(trafficUpdateListener);
 | 
				
			||||||
 | 
					        tencentMap.setTrafficEnabled(true);
 | 
				
			||||||
 | 
					        tencentMap.setIndoorEnabled(true);
 | 
				
			||||||
 | 
					        handScreen.postDelayed(runScreenShot, 2000);
 | 
				
			||||||
 | 
					        //runOnUiThread(runScreenShot);
 | 
				
			||||||
 | 
					        imgView = (ImageView) this.findViewById(R.id.imgview);
 | 
				
			||||||
 | 
					        imgView.setScaleType(ImageView.ScaleType.CENTER);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    protected void onPause() {
 | 
				
			||||||
 | 
					        // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					        super.onPause();
 | 
				
			||||||
 | 
					        mapview.onPause();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @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();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onCreateOptionsMenu(Menu menu) {
 | 
				
			||||||
 | 
					        // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					        menu.add(0, 1, 0, "截屏坐标1");
 | 
				
			||||||
 | 
					        menu.add(0, 2, 0, "截屏坐标2");
 | 
				
			||||||
 | 
					        return super.onCreateOptionsMenu(menu);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean onOptionsItemSelected(MenuItem item) {
 | 
				
			||||||
 | 
					        // TODO Auto-generated method stub
 | 
				
			||||||
 | 
					        switch (item.getItemId()) {
 | 
				
			||||||
 | 
					            case 1:
 | 
				
			||||||
 | 
					                setCoord1();
 | 
				
			||||||
 | 
					                handScreen.postDelayed(runScreenShot, 2000);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case 2:
 | 
				
			||||||
 | 
					                setCoor2();
 | 
				
			||||||
 | 
					                handScreen.postDelayed(runScreenShot, 2000);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return super.onOptionsItemSelected(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void setCoord1() {
 | 
				
			||||||
 | 
					        CameraUpdate update = CameraUpdateFactory.newCameraPosition(camerPosition_GUGONG);
 | 
				
			||||||
 | 
					        tencentMap.moveCamera(update);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void setCoor2() {
 | 
				
			||||||
 | 
					        CameraUpdate update = CameraUpdateFactory.newCameraPosition(camerPosition_YINKE);
 | 
				
			||||||
 | 
					        tencentMap.moveCamera(update);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||