Commit 266443a5 by luo_sp

第一次提交代码

parents
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/arcgislib" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SerialVersionUIDNotStaticFinal" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreAnonymousInnerClasses" value="false" />
<option name="superClassString" value="java.awt.Component" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="org.jetbrains.annotations.Nullable" />
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="12">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="android.annotation.Nullable" />
<item index="7" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="11" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="11">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="android.annotation.NonNull" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="10" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "cn.com.founder.arcgisserver"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
ndk{
abiFilters "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.android.support:multidex:1.0.3'
implementation project(path: ':arcgislib')
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package cn.com.founder.arcgisserver;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("cn.com.founder.arcgisserver", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cn.com.founder.arcgisserver"
android:installLocation="preferExternal"
>
<application
android:name=".MyApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true"
tools:ignore="GoogleAppIndexingWarning"
tools:targetApi="q">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package cn.com.founder.arcgisserver;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import cn.com.founder.arcgislib.ArcGisFounder;
import cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption;
import cn.com.founder.arcgislib.compass.option.IArcGisCompassOption;
import cn.com.founder.arcgislib.location.option.IArcGisLocationOption;
import cn.com.founder.arcgislib.view.ArcGisBaseView;
import cn.com.founder.arcgislib.zoom.listener.IZoomClickListener;
import cn.com.founder.arcgislib.zoom.option.IArcGisZoomOption;
public class MainActivity extends AppCompatActivity {
// private LifecycleRegistry mLifecycleRegistry;
/**
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArcGisBaseView arcGisBaseView = findViewById(R.id.main_arc_gis_base_view);
//集成Activity
// mLifecycleRegistry = new LifecycleRegistry(this);
// mLifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE);
ArcGisFounder arcGisFounder = ArcGisFounder.with(this)//context
.setParentLayout(arcGisBaseView)//设置父布局
.setLifecycle(getLifecycle())//生命周期管理
.setBackgroundGridColor(Color.WHITE)//设置地图网格背景色
.setBackgroundGridLineColor(Color.LTGRAY)//设置地图网格线颜色
.setBackgroundGridLineWidth(1f)//设置地图网格线宽度
.setDefaultArcGisLocation()//设置默认定位
.setDefaultArcGisZoom()//设置默认缩放
.setDefaultArcGisCompass()//设置默认罗盘
.setOpenNavi()//开启导航
// .setOpenSearch()//开启搜索
.setOpenHotPots()//开启热力图
.setOpenCluster()//开启聚合
.createArcGisFounder();//创建ArcGisFounder地图实例
IArcGisZoomOption iArcGisZoomOption = arcGisFounder.arcGisZoomOption();
iArcGisZoomOption.setShowText(false);
iArcGisZoomOption.setZoomClickListener(new IZoomClickListener() {
@Override
public void zoomInClick(View view, double scale) {
Toast.makeText(MainActivity.this, scale + "", Toast.LENGTH_LONG).show();
}
@Override
public void zoomOutClick(View view, double scale) {
Toast.makeText(MainActivity.this, scale + "", Toast.LENGTH_LONG).show();
}
});
IArcGisLocationOption iArcGisLocationOption = arcGisFounder.arcGisLocationOption();
//自动定位
// iArcGisLocationOption.startLocation(0);
//手动定位
iArcGisLocationOption.startLocation(113.75179,23.02067,0);
//开启导入
iArcGisLocationOption.setShowImportLayout(true);
//移动地图获取中心点
// iArcGisLocationOption.setFollowMapViewPoint(true);
//隐藏poi信息
iArcGisLocationOption.getCalloutContentBuilder().setmPoiHide(true);
iArcGisLocationOption.setLocationChangeListener(locationModel -> {
Toast.makeText(MainActivity.this, "X:" + locationModel.getXPoint()
+ "\nY:" + locationModel.getYPoint()
+ "\n地址:" + locationModel.getAddress()
+ "\nPoi:" + locationModel.getPoi()
+ "\n补充信息:" + locationModel.getExtraInfo()
+ "\n操作类型:"+locationModel.getLocationChangeType(), Toast.LENGTH_LONG).show();
}
);
iArcGisLocationOption.getCalloutStyleBuilder().setCalloutBorderWidth(2);
iArcGisLocationOption.getCalloutContentBuilder().setmCancelHide(true);
IArcGisCompassOption iArcGisCompassOption = arcGisFounder.arcGisCompassOption();
iArcGisCompassOption.setIRotationAngleListener(() -> Toast.makeText(MainActivity.this, "转动结束。。。", Toast.LENGTH_LONG).show());
IArcGisClusterOption iArcGisClusterOption = arcGisFounder.arcGisClusterOption();
iArcGisClusterOption.setCluseterData(null);
}
}
\ No newline at end of file
package cn.com.founder.arcgisserver;
import android.app.Application;
import androidx.multidex.MultiDex;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/12 10:01
* EMail:luo_shaopeng@founder.com.cn
* Description:toDo
*/
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<cn.com.founder.arcgislib.view.ArcGisBaseView
android:id="@+id/main_arc_gis_base_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
</resources>
<resources>
<string name="app_name">ArcGisServer</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
package cn.com.founder.arcgisserver;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "0.0.2"
consumerProguardFiles 'consumer-rules.pro'
ndk{
abiFilters "armeabi-v7a"
// abiFilters "arm64-v8a"
// abiFilters "armeabi"
}
}
buildTypes {
release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
packagingOptions {
exclude 'assets/tnavi/HCI_AUTH/HCI_AUTH_FOREVER'
exclude 'assets/tnavi/log/gpspos_data.txt'
exclude 'assets/tnavi/pdata/fx.sdb'
exclude 'assets/tnavi/pdata/font.pdt'
exclude 'assets/tnavi/pdata/res.pdt'
exclude 'assets/tnavi/sdb/cdata/rsh_0.sdb'
exclude 'assets/tnavi/sdb/cdata/zon.sdb'
exclude 'assets/tnavi/sdb/cdata/man.cdt'
exclude 'assets/tnavi/sdb/cdata/rsh.sdb'
exclude 'assets/tnavi/sdb/cdata/url.cdt'
exclude 'assets/tnavi/sdb/cdata/gd.sdb'
exclude 'assets/tnavi/sdb/cdata/ano.cdt'
exclude 'assets/tnavi/sdb/adata/tmp'
exclude 'assets/tnavi/config.ini'
exclude 'assets/tnavi/Dictionary.Dat'
exclude 'assets/tnavi/udata/utmp.txt'
exclude 'assets/tnavi/DictionaryWordSort.dat'
exclude 'assets/AccountInfo.txt'
}
}
dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
//arcgis地图
implementation 'com.esri.arcgisruntime:arcgis-android:100.6.0'
//权限
implementation 'com.yanzhenjie:permission:2.0.3'
//导航
implementation 'com.jakewharton.timber:timber:4.5.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.mapzen.android:lost:2.1.2'
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
}
apply from: '../mvn_push.gradle'
ARTIFACT_ID = map
VERSION = 0.0.1
PACKAGING = aar
DESCRIPTION = first create map lib
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#############################################
#
# 对于一些基本指令的添加
#
#############################################
# 代码混淆压缩比,在0~7之间,默认为5,一般不做修改
-optimizationpasses 5
# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames
# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses
# 这句话能够使我们的项目混淆后产生映射文件
# 包含有类名->混淆后类名的映射关系
-verbose
# 指定不去忽略非公共库的类成员
-dontskipnonpubliclibraryclassmembers
# 不做预校验,preverify是proguard的四个步骤之一,Android不需要preverify,去掉这一步能够加快混淆速度。
-dontpreverify
# 保留Annotation不混淆
-keepattributes *Annotation*,InnerClasses
# 避免混淆泛型
-keepattributes Signature
# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable
# 指定混淆是采用的算法,后面的参数是一个过滤器
# 这个过滤器是谷歌推荐的算法,一般不做更改
-optimizations !code/simplification/cast,!field/*,!class/merging/*
# 可以把代码以及所使用到的各种第三方库代码统统移动到同一个包下
-repackageclasses cn.com.founder.arcgislib.view
#############################################
#
# Android开发中一些需要保留的公共部分
#
#############################################
# 保留我们使用的四大组件,自定义的Application等等这些类不被混淆
# 因为这些子类都有可能被外部调用
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Appliction
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class * extends android.view.View
-keep public class com.android.vending.licensing.ILicensingService
# 保留support下的所有类及其内部类
-keep class android.support.** {*;}
# 保留继承的
-keep public class * extends android.support.v4.**
-keep public class * extends android.support.v7.**
-keep public class * extends android.support.annotation.**
# 保留R下面的资源
-keep class **.R$* {*;}
# 保留本地native方法不被混淆
-keepclasseswithmembernames class * {
native <methods>;
}
# 保留在Activity中的方法参数是view的方法,
# 这样以来我们在layout中写的onClick就不会被影响
-keepclassmembers class * extends android.app.Activity{
public void *(android.view.View);
}
# 保留枚举类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# 保留我们自定义控件(继承自View)不被混淆
-keep public class * extends android.view.View{
*** get*();
void set*(***);
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
# 保留Parcelable序列化类不被混淆
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
# 保留Serializable序列化的类不被混淆
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# 对于带有回调函数**On*Listener的,不能被混淆
-keepclassmembers class * {
void *(**On*Listener);
}
#-------------- okhttp3 start-------------
# OkHttp3
# https://github.com/square/okhttp
# okhttp
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.* { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
# okhttp 3
-keepattributes Signature
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
# Okio
-dontwarn com.squareup.**
-dontwarn okio.**
-keep public class org.codehaus.* { *; }
-keep public class java.nio.* { *; }
#----------okhttp end--------------
-keep class com.esri.arcgisruntime.**{ *; }
-dontwarn com.esri.arcgisruntime.**
-keep class cn.com.founder.arcgislib.ArcGisFounder{ *; }
-keepclassmembers class cn.com.founder.arcgislib.ArcGisFounder$ArcGisFounderBuilder{
public *;
}
-keepclassmembers class cn.com.founder.arcgislib.view.ArcGisLocationView$CalloutStyleBuilder{
public *;
}
-keepclassmembers class cn.com.founder.arcgislib.view.ArcGisLocationView$CalloutContentBuilder{
public *;
}
-keep class cn.com.founder.arcgislib.location.listener.**{ *; }
-keep class cn.com.founder.arcgislib.location.option.**{ *; }
-keep class cn.com.founder.arcgislib.compass.listener.**{ *; }
-keep class cn.com.founder.arcgislib.compass.option.**{ *; }
-keep class cn.com.founder.arcgislib.zoom.listener.**{ *; }
-keep class cn.com.founder.arcgislib.zoom.option.**{ *; }
-keep class cn.com.founder.arcgislib.search.listener.**{ *; }
-keep class cn.com.founder.arcgislib.search.option.**{ *; }
-keep class cn.com.founder.arcgislib.navi.option.**{ *; }
-keep class cn.com.founder.arcgislib.cluster.option.**{ *; }
-keep class cn.com.founder.arcgislib.hotpots.option.**{ *; }
-keep class cn.com.founder.arcgislib.model.**{ *; }
-keep class cn.com.founder.arcgislib.view.**{ *; }
-keep class cn.com.founder.arcgislib.widget.cluster.**{ *; }
-keep class cn.com.founder.arcgislib.widget.navi.**{ *; }
-keep class cn.com.founder.arcgislib.widget.popup.**{ *; }
-keep class cn.com.founder.arcgislib.widget.scrolllayout.**{ *; }
-keep class cn.com.founder.arcgislib.widget.scrolllayout.content.**{ *; }
-keep class cn.com.founder.arcgislib.widget.scrolllayout{ *; }
-keepclassmembers class cn.com.founder.arcgislib.widget.scrolllayout$Status{
public *;
}
-keep class com.minedata.minenavi.**{ *; }
-dontwarn com.minedata.minenavi.**
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="cn.com.founder.arcgislib">
<!--网络-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--定位-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!--导航-->
<!-- 允许在SDCard中创建与删除文件 -->
<uses-permission
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
tools:ignore="ProtectedPermissions" />
<!--允许不同用户的应用之间可以产生交互-->
<uses-permission
android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
tools:ignore="ProtectedPermissions" />
<!-- 允许程序打开网络套接字 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 允许程序访问网络状态 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 允许用户改变WiFi连接状态 -->
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<!-- 程序访问粗略位置 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 允许用户访问精确位置 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 允许程序读取手机状态 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- 打电话的权限 -->
<uses-permission android:name="android.permission.CALL_PHONE" />
<!-- 允许程序写入外部存储设备 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 允许程序读取所有者数据 -->
<uses-permission android:name="android.permission.READ_OWNER_DATA" />
<!-- 访问WiFi状态,需要WiFi信息用于网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 访问网络的变化, 需要某些信息用于网络定位 -->
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<!--8.0 安装未知程序权限-->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<!-- 允许程序读取日志 -->
<uses-permission android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions"/>
<!--arcgis地图 2D-->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="n" />
</manifest>
package cn.com.founder.arcgislib.cluster;
import com.esri.arcgisruntime.geometry.Point;
import java.util.List;
import cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.view.ArcGisClusterView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/16 15:55
* EMail:luo_shaopeng@founder.com.cn
* Description:聚合
*/
public class ArcGisCluster implements IArcGisClusterOption {
/**
* {@link ArcGisClusterView}
*/
private ArcGisClusterView mArcGisClusterView;
public ArcGisCluster(ArcGisClusterView arcGisClusterView) {
this.mArcGisClusterView = arcGisClusterView;
}
@Override
public IArcGisClusterOption setShowClusterLayout(boolean isShow) {
mArcGisClusterView.setShowClusterLayout(isShow);
return this;
}
@Override
public IArcGisClusterOption setClusterViewLocation(Variable.ViewLocation location) {
mArcGisClusterView.setClusterViewLocation(location);
return this;
}
@Override
public IArcGisClusterOption setClusterImage(int clusterImage) {
mArcGisClusterView.setClusterImage(clusterImage);
return this;
}
@Override
public IArcGisClusterOption setCluseterData(List<Point> pointList) {
mArcGisClusterView.setClusterData(pointList);
return this;
}
}
package cn.com.founder.arcgislib.cluster.option;
import com.esri.arcgisruntime.geometry.Point;
import java.util.List;
import cn.com.founder.arcgislib.common.Variable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/16 15:56
* EMail:luo_shaopeng@founder.com.cn
* Description:聚合
*/
public interface IArcGisClusterOption {
/**
* @param isShow boolean-是否显示聚合布局
* 默认显示
*/
IArcGisClusterOption setShowClusterLayout(boolean isShow);
/**
* @param location {@link Variable.ViewLocation } ClusterView显示位置
*/
IArcGisClusterOption setClusterViewLocation(Variable.ViewLocation location);
/**
* @param clusterImage int(资源ID)-聚合图片
*/
IArcGisClusterOption setClusterImage(int clusterImage);
/**
* @param pointList 聚合点集合
*/
IArcGisClusterOption setCluseterData(List<Point> pointList);
}
package cn.com.founder.arcgislib.common;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 17:37
* EMail:luo_shaopeng@founder.com.cn
* Description:共同变量
*/
public class Variable {
public static enum DrawType {
TEXT,
POINT,
LINE,
POLYGON;
}
public static enum GraphType {
LINE,
POLYGON,
ORTHOGON,
CIRCLE,
ELLIPSE,
RHOMBUS;
}
public static enum Measure {
M,
KM,
KIM,
M2,
KM2,
HM2,
A2;
}
public static enum LayerType {
TILE,
WMTS,
IMG,
BUNDLE
}
public static enum ViewLocation{
LEFT_TOP,
RIGHT_TOP,
CENTER,
LEFT_BOTTOM,
RIGHT_BOTTOM
}
public static enum TouchUp{
UP,
RORATE,
LONG_PRESS
}
public static enum CalloutLeaderPosition{
DEFAULT,
AUTO
}
public static enum SearchType{
NONE,
SEARCH,
START_ADDRESS_SEARCH,
END_ADDRESS_SEARCH,
}
public static enum InputCalendar{
START,
END
}
public static enum LocationChangeType implements Parcelable {
STARTA_LOCATION,
MOVE_MAP,
CLICK_MAP,
IMPORT_POINT,
CALLOUT_OK;
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(ordinal());
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<LocationChangeType> CREATOR = new Creator<LocationChangeType>() {
@Override
public LocationChangeType createFromParcel(Parcel in) {
return LocationChangeType.values()[in.readInt()];
}
@Override
public LocationChangeType[] newArray(int size) {
return new LocationChangeType[size];
}
};
}
}
package cn.com.founder.arcgislib.compass;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.compass.listener.IOnClickListener;
import cn.com.founder.arcgislib.compass.listener.IRotationListener;
import cn.com.founder.arcgislib.compass.option.IArcGisCompassOption;
import cn.com.founder.arcgislib.view.ArcGisMapCompassView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 14:20
* EMail:luo_shaopeng@founder.com.cn
* Description:罗盘操作
*/
public class ArcGisCompass implements IArcGisCompassOption {
/**
* {@link ArcGisMapCompassView}
*/
private ArcGisMapCompassView mArcGisMapCompassView;
public ArcGisCompass(ArcGisMapCompassView arcGisMapCompassView) {
this.mArcGisMapCompassView = arcGisMapCompassView;
}
/**
* @param isShow boolean-是否显示罗盘布局
*/
@Override
public IArcGisCompassOption setShowCompassLayout(boolean isShow) {
mArcGisMapCompassView.setShowCompassLayout(isShow);
return this;
}
/**
* @param location {@link Variable.ViewLocation } CompassView显示位置
*/
@Override
public IArcGisCompassOption setCompassViewLocation(Variable.ViewLocation location) {
mArcGisMapCompassView.setCompassViewLocation(location);
return this;
}
/**
* @param compassImage int(资源ID)-罗盘图片
*/
@Override
public IArcGisCompassOption setCompassImage(int compassImage) {
mArcGisMapCompassView.setCompassImage(compassImage);
return this;
}
/**
* @param iOnClickListener 罗盘点击事件
*/
@Override
public IArcGisCompassOption setOnClik(IOnClickListener iOnClickListener) {
mArcGisMapCompassView.setIOnClik(iOnClickListener);
return this;
}
/**
* @param iRotationListener 罗盘旋转事件
*/
@Override
public IArcGisCompassOption setIRotationAngleListener(IRotationListener iRotationListener) {
mArcGisMapCompassView.setIRotationListener(iRotationListener);
return this;
}
}
package cn.com.founder.arcgislib.compass.listener;
import android.view.View;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 14:48
* EMail:luo_shaopeng@founder.com.cn
* Description:点击事件
*/
public interface IOnClickListener {
/**
* @param v 点击罗盘监听
*/
void onClick(View v);
}
package cn.com.founder.arcgislib.compass.listener;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 15:27
* EMail:luo_shaopeng@founder.com.cn
* Description:地图旋转接口
*/
public interface IRotationListener {
/**
* 旋转监听
*/
void iRotationAngleListener();
}
package cn.com.founder.arcgislib.compass.option;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.compass.listener.IOnClickListener;
import cn.com.founder.arcgislib.compass.listener.IRotationListener;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 14:21
* EMail:luo_shaopeng@founder.com.cn
* Description:罗盘操作
*/
public interface IArcGisCompassOption {
/**
* @param isShow boolean-是否显示罗盘布局
* 默认显示
*/
IArcGisCompassOption setShowCompassLayout(boolean isShow);
/**
* @param location {@link Variable.ViewLocation } CompassView显示位置
*/
IArcGisCompassOption setCompassViewLocation(Variable.ViewLocation location);
/**
* @param compassImage int(资源ID)-罗盘图片
*/
IArcGisCompassOption setCompassImage(int compassImage);
/**
* @param iOnClickListener 罗盘点击事件
* @return
*/
IArcGisCompassOption setOnClik(IOnClickListener iOnClickListener);
/**
* @param iRotationListener 罗盘旋转事件
*/
IArcGisCompassOption setIRotationAngleListener(IRotationListener iRotationListener);
}
package cn.com.founder.arcgislib.constants;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 15:41
* EMail:luo_shaopeng@founder.com.cn
* Description:Url 管理
*/
public class Constants {
/**
* 测试热力图
*/
private static String hotPotsUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";
/**
* argis证书
*/
private static String baseRunTime = "runtimelite,1000,rud9526010123,none,XXMFA0PL4S0MC2EN0175";
/**
* 天地图key,使用的是服务器端
*/
private static String baseTianDiTuKey = "39edeab91620fe3c5a1b282228ef6e46";
private static String baseTianDiTuGeoUrl = "http://api.tianditu.gov.cn/geocoder";
//互联网-地图
private static String baseUrl = "http://47.92.225.109:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//公安网-地图
// private static String baseUrl = "http://68.174.69.45:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//用户网-地图
// private static String baseUrl = "http://20.97.50.41:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//互联网-搜索接口
private static String searchUrl = "http://47.92.226.24:8051/selectPoiDataList";
//公安网-搜索接口
// private static String searchUrl = "http://68.174.69.46:8051/selectPoiDataList";
//用户网
// private static String searchUrl = "http://20.97.50.41:8051/selectPoiDataList";
//arcGis证书
public static final String BASE_MAP_RUNTIME = baseRunTime;
//服务器Url
public static final String BASE_MAP_SERVER_URL = baseUrl;
//天地图
public static final String BASE_TIANDITU_KEY = baseTianDiTuKey;
//逆地理编码查询
public static final String BASE_TIANDITU_GEO_URL = baseTianDiTuGeoUrl;
//搜索
public static final String BASE_SEARCH_URL = searchUrl;
//热力图
public static final String BASE_HOT_POTS_URL = hotPotsUrl;
}
package cn.com.founder.arcgislib.hotpots;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.hotpots.option.IArcGisHotPotsOption;
import cn.com.founder.arcgislib.view.ArcGisHotPotsView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/15 17:33
* EMail:luo_shaopeng@founder.com.cn
* Description:热力图
*/
public class ArcGisHotPots implements IArcGisHotPotsOption {
/**
* {@link ArcGisHotPotsView}
*/
private ArcGisHotPotsView mArcGisHotPots;
public ArcGisHotPots(ArcGisHotPotsView mArcGisHotPots) {
this.mArcGisHotPots = mArcGisHotPots;
}
@Override
public IArcGisHotPotsOption setShowHotPotsLayout(boolean isShow) {
mArcGisHotPots.setShowHotPotsLayout(isShow);
return this;
}
@Override
public IArcGisHotPotsOption setHotPotsViewLocation(Variable.ViewLocation location) {
mArcGisHotPots.setHotPotsViewLocation(location);
return this;
}
@Override
public IArcGisHotPotsOption setHotPotsImage(int hotPotsImage) {
mArcGisHotPots.setHotPotsImage(hotPotsImage);
return this;
}
}
package cn.com.founder.arcgislib.hotpots.option;
import cn.com.founder.arcgislib.common.Variable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/15 17:34
* EMail:luo_shaopeng@founder.com.cn
* Description:热力图
*/
public interface IArcGisHotPotsOption {
/**
* @param isShow boolean-是否显示热力图布局
* 默认隐藏
*/
IArcGisHotPotsOption setShowHotPotsLayout(boolean isShow);
/**
* @param location {@link Variable.ViewLocation } HotPotsView显示位置
*/
IArcGisHotPotsOption setHotPotsViewLocation(Variable.ViewLocation location);
/**
* @param hotPotsImage int(资源ID)-热力图图片
*/
IArcGisHotPotsOption setHotPotsImage(int hotPotsImage);
}
package cn.com.founder.arcgislib.location;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.location.listener.ILocationChangeListener;
import cn.com.founder.arcgislib.location.option.IArcGisLocationOption;
import cn.com.founder.arcgislib.view.ArcGisLocationView;
import cn.com.founder.arcgislib.view.ArcGisMapView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/5 15:17
* EMail:luo_shaopeng@founder.com.cn
* Description:位置操作
*/
public class ArcGisLocation implements IArcGisLocationOption {
/**
* {@link ArcGisMapView}
*/
private ArcGisLocationView mArcGisLocationView;
public ArcGisLocation(ArcGisLocationView arcGisLocationView) {
this.mArcGisLocationView = arcGisLocationView;
}
/**
* 获取当前位置 默认值5d
*/
@Override
public IArcGisLocationOption startLocation(double scale) {
mArcGisLocationView.startLocation(scale);
return this;
}
/**
* @param x x点
* @param y 点
*/
@Override
public IArcGisLocationOption startLocation(double x, double y, double scale) {
mArcGisLocationView.startLocation(x, y, scale);
return this;
}
/**
* @param locationChangeListener 设置位置监听
*/
@Override
public IArcGisLocationOption setLocationChangeListener(ILocationChangeListener locationChangeListener) {
mArcGisLocationView.setILocationChangeListener(locationChangeListener);
return this;
}
/**
* @return 停止定位
*/
@Override
public IArcGisLocationOption stopLocation() {
mArcGisLocationView.stopLocation();
return this;
}
/**
* @param isShow boolean-是否显示定位布局
*/
@Override
public IArcGisLocationOption setShowLocationLayout(boolean isShow) {
mArcGisLocationView.setShowLocationLayout(isShow);
return this;
}
/**
* @param isShow boolean-是否显示导入布局
*/
@Override
public IArcGisLocationOption setShowImportLayout(boolean isShow) {
mArcGisLocationView.setShowImportLayout(isShow);
return this;
}
/**
* @param location {@link Variable.ViewLocation } LocationView显示位置
*/
@Override
public IArcGisLocationOption setLocationViewLocation(Variable.ViewLocation location) {
mArcGisLocationView.setLocationViewLocation(location);
return this;
}
/**
* @param locationImage int(资源ID)-定位图片
*/
@Override
public IArcGisLocationOption setLocationImage(int locationImage) {
mArcGisLocationView.setLocationImage(locationImage);
return this;
}
/**
* @param importImage int(资源ID)-导入图片
*/
@Override
public IArcGisLocationOption setImportImage(int importImage) {
mArcGisLocationView.setImportImage(importImage);
return this;
}
/**
* @param centerLocationImage int(资源ID)-中心位置图片
*/
@Override
public IArcGisLocationOption setCenterLocationImage(int centerLocationImage) {
mArcGisLocationView.setCenterLocationImage(centerLocationImage);
return this;
}
/**
* @param labelLocationNormalImage int(资源ID)-标记位置正常图片
*/
@Override
public IArcGisLocationOption setLabelLocationNormalImage(int labelLocationNormalImage) {
mArcGisLocationView.setLabelLocationNormalImage(labelLocationNormalImage);
return this;
}
/**
* @param labelLocationSelectedImage int(资源ID)-标记位置选中图片
*/
@Override
public IArcGisLocationOption setLabelLocationSelectedImage(int labelLocationSelectedImage) {
mArcGisLocationView.setLabelLocationSelectedImage(labelLocationSelectedImage);
return this;
}
/**
* @param isFollow 设置是否跟随地图获取中心点
*/
@Override
public IArcGisLocationOption setFollowMapViewPoint(boolean isFollow) {
mArcGisLocationView.setFollowMapViewPoint(isFollow);
return this;
}
@Override
public ArcGisLocationView.CalloutStyleBuilder getCalloutStyleBuilder() {
return mArcGisLocationView.getCalloutStyleBuilder();
}
@Override
public ArcGisLocationView.CalloutContentBuilder getCalloutContentBuilder() {
return mArcGisLocationView.getCalloutContentBuilder();
}
}
package cn.com.founder.arcgislib.location.listener;
import cn.com.founder.arcgislib.model.LocationModel;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/7 17:00
* EMail:luo_shaopeng@founder.com.cn
* Description:位置改变监听
*/
public interface ILocationChangeListener {
/**
* 位置信息回调
* @param locationModel {@link LocationModel}
*/
void locationCallBack(LocationModel locationModel);
}
package cn.com.founder.arcgislib.location.option;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.location.listener.ILocationChangeListener;
import cn.com.founder.arcgislib.view.ArcGisLocationView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/5 15:18
* EMail:luo_shaopeng@founder.com.cn
* Description:位置
*/
public interface IArcGisLocationOption {
/**
* 开始定位
* @param scale 初始地图Zoom层级 默认4d
*/
IArcGisLocationOption startLocation(double scale);
/**
* 手动定位
* @param x x点
* @param y 点
*/
IArcGisLocationOption startLocation(double x, double y,double scale);
/**
* @param locationChangeListener 设置位置监听
*/
IArcGisLocationOption setLocationChangeListener(ILocationChangeListener locationChangeListener);
/**
* @return 停止获取位置
*/
IArcGisLocationOption stopLocation();
/**
* @param isShow boolean-是否显示定位布局
* 默认显示
*/
IArcGisLocationOption setShowLocationLayout(boolean isShow);
/**
* @param isShow boolean-是否显示导入布局
* 默认隐藏
*/
IArcGisLocationOption setShowImportLayout(boolean isShow);
/**
* @param location {@link Variable.ViewLocation } LocationView显示位置
*/
IArcGisLocationOption setLocationViewLocation(Variable.ViewLocation location);
/**
* @param locationImage int(资源ID)-定位图片
*/
IArcGisLocationOption setLocationImage(int locationImage);
/**
* @param importImage int(资源ID)-导入图片
*/
IArcGisLocationOption setImportImage(int importImage);
/**
* @param centerLocationImage int(资源ID)-中心位置图片
*/
IArcGisLocationOption setCenterLocationImage(int centerLocationImage);
/**
* @param labelLocationNormalImage int(资源ID)-标记位置正常图片
*/
IArcGisLocationOption setLabelLocationNormalImage(int labelLocationNormalImage);
/**
* @param labelLocationSelectedImage int(资源ID)-标记位置选中图片
*/
IArcGisLocationOption setLabelLocationSelectedImage(int labelLocationSelectedImage);
/**
* @param isFollow 设置是否跟随地图获取中心点
* 默认不跟随
*/
IArcGisLocationOption setFollowMapViewPoint(boolean isFollow);
/**
* callout样式
*/
ArcGisLocationView.CalloutStyleBuilder getCalloutStyleBuilder();
/**
* callout内容样式
*/
ArcGisLocationView.CalloutContentBuilder getCalloutContentBuilder();
}
package cn.com.founder.arcgislib.model;
import android.os.Parcel;
import android.os.Parcelable;
import cn.com.founder.arcgislib.common.Variable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/7 17:32
* EMail:luo_shaopeng@founder.com.cn
* Description:位置数据模型
*/
public class LocationModel implements Parcelable {
/**
* x点
*/
private double xPoint;
/**
* y点
*/
private double yPoint;
/**
* 地址
*/
private String address;
/**
* poi
*/
private String poi;
/**
* 补充信息
*/
private String extraInfo;
private Variable.LocationChangeType locationChangeType;
public LocationModel(double xPoint, double yPoint, String address, String poi, String extraInfo, Variable.LocationChangeType locationChangeType) {
this.xPoint = xPoint;
this.yPoint = yPoint;
this.address = address;
this.poi = poi;
this.extraInfo = extraInfo;
this.locationChangeType = locationChangeType;
}
private LocationModel(Parcel in){
xPoint = in.readDouble();
yPoint = in.readDouble();
address = in.readString();
poi = in.readString();
extraInfo = in.readString();
locationChangeType = in.readParcelable(Variable.LocationChangeType.class.getClassLoader());
}
public static final Creator<LocationModel> CREATOR = new Creator<LocationModel>() {
@Override
public LocationModel createFromParcel(Parcel in) {
return new LocationModel(in);
}
@Override
public LocationModel[] newArray(int size) {
return new LocationModel[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeDouble(xPoint);
parcel.writeDouble(yPoint);
parcel.writeString(address);
parcel.writeString(poi);
parcel.writeString(extraInfo);
parcel.writeParcelable(locationChangeType,i);
}
/**
* @return double-得到X点
*/
public double getXPoint() {
return xPoint;
}
/**
* @param xPoint 设置X点
*/
public void setXPoint(double xPoint) {
this.xPoint = xPoint;
}
/**
* @return double-得到Y点
*/
public double getYPoint() {
return yPoint;
}
/**
* @param yPoint 设置Y点
*/
public void setYPoint(double yPoint) {
this.yPoint = yPoint;
}
/**
* @return String-得到地址
*/
public String getAddress() {
return address;
}
/**
* @param address 设置地址
*/
public void setAddress(String address) {
this.address = address;
}
/**
* @return String-得到poi
*/
public String getPoi() {
return poi;
}
/**
* @param poi 设置poi
*/
public void setPoi(String poi) {
this.poi = poi;
}
/**
* @return String-得到补充信息
*/
public String getExtraInfo() {
return extraInfo;
}
/**
* @param extraInfo 设置补充信息
*/
public void setExtraInfo(String extraInfo) {
this.extraInfo = extraInfo;
}
public Variable.LocationChangeType getLocationChangeType() {
return locationChangeType;
}
public void setLocationChangeType(Variable.LocationChangeType locationChangeType) {
this.locationChangeType = locationChangeType;
}
}
package cn.com.founder.arcgislib.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/13 17:05
* EMail:luo_shaopeng@founder.com.cn
* Description:搜索结果
*/
public class SearchModel implements Parcelable {
/**
* 名称
*/
private String poiname;
/**
* 地址
*/
private String poiaddress;
/**
* 经度 longitude
*/
private double x;
/**
* 纬度 latitude
*/
private double y;
public SearchModel(){}
public SearchModel(Parcel in){
poiname = in.readString();
poiaddress = in.readString();
x = in.readDouble();
y = in.readDouble();
}
public static final Creator<SearchModel> CREATOR = new Creator<SearchModel>() {
@Override
public SearchModel createFromParcel(Parcel in) {
return new SearchModel(in);
}
@Override
public SearchModel[] newArray(int size) {
return new SearchModel[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(poiname);
parcel.writeString(poiaddress);
parcel.writeDouble(x);
parcel.writeDouble(y);
}
public String getPoiname() {
return poiname;
}
public void setPoiname(String poiname) {
this.poiname = poiname;
}
public String getPoiaddress() {
return poiaddress;
}
public void setPoiaddress(String poiaddress) {
this.poiaddress = poiaddress;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
}
package cn.com.founder.arcgislib.navi;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.navi.option.IArcGisNaviOption;
import cn.com.founder.arcgislib.view.ArcGisNaviView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/11 13:37
* EMail:luo_shaopeng@founder.com.cn
* Description:导航操作
*/
public class ArcGisNavi implements IArcGisNaviOption {
/**
* {@link ArcGisNaviView}
*/
private ArcGisNaviView mArcGisNaviView;
public ArcGisNavi(ArcGisNaviView arcGisNaviView) {
this.mArcGisNaviView = arcGisNaviView;
}
@Override
public IArcGisNaviOption setShowNaviLayout(boolean isShow) {
mArcGisNaviView.setShowNaviLayout(isShow);
return this;
}
@Override
public IArcGisNaviOption setNaviViewLocation(Variable.ViewLocation location) {
mArcGisNaviView.setNaviViewLocation(location);
return this;
}
@Override
public IArcGisNaviOption setNaviImage(int naviImage) {
mArcGisNaviView.setNaviImage(naviImage);
return this;
}
}
package cn.com.founder.arcgislib.navi.option;
import cn.com.founder.arcgislib.common.Variable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/11 13:40
* EMail:luo_shaopeng@founder.com.cn
* Description:导航操作
*/
public interface IArcGisNaviOption {
/**
* @param isShow boolean-是否显示导航布局
* 默认隐藏
*/
IArcGisNaviOption setShowNaviLayout(boolean isShow);
/**
* @param location {@link Variable.ViewLocation } NaviView显示位置
*/
IArcGisNaviOption setNaviViewLocation(Variable.ViewLocation location);
/**
* @param naviImage int(资源ID)-导航图片
*/
IArcGisNaviOption setNaviImage(int naviImage);
}
package cn.com.founder.arcgislib.option;
import cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption;
import cn.com.founder.arcgislib.compass.option.IArcGisCompassOption;
import cn.com.founder.arcgislib.hotpots.option.IArcGisHotPotsOption;
import cn.com.founder.arcgislib.location.option.IArcGisLocationOption;
import cn.com.founder.arcgislib.navi.option.IArcGisNaviOption;
import cn.com.founder.arcgislib.search.option.IArcGisSearchOption;
import cn.com.founder.arcgislib.zoom.option.IArcGisZoomOption;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:23
* EMail:luo_shaopeng@founder.com.cn
* Description:地图操作
*/
public interface IOption {
/**
* 位置操作
*/
IArcGisLocationOption arcGisLocationOption();
/**
* 缩放操作
*/
IArcGisZoomOption arcGisZoomOption();
/**
* 罗盘操作
*/
IArcGisCompassOption arcGisCompassOption();
/**
* 导航操作
*/
IArcGisNaviOption arcGisNaviOption();
/**
* 搜索操作
*/
IArcGisSearchOption arcGisSearchOption();
/**
* 热力图操作
*/
IArcGisHotPotsOption arcGisHotPotsOption();
/**
* 聚合操作
*/
IArcGisClusterOption arcGisClusterOption();
}
package cn.com.founder.arcgislib.search;
import cn.com.founder.arcgislib.search.option.IArcGisSearchOption;
import cn.com.founder.arcgislib.view.ArcGisSearchView;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/11 19:37
* EMail:luo_shaopeng@founder.com.cn
* Description:搜索
*/
public class ArcGisSearch implements IArcGisSearchOption {
/**
* {@link ArcGisSearchView}
*/
private ArcGisSearchView mArcGisSearchView;
public ArcGisSearch(ArcGisSearchView arcGisSearchView) {
this.mArcGisSearchView = arcGisSearchView;
}
}
package cn.com.founder.arcgislib.search.listener;
import cn.com.founder.arcgislib.model.SearchModel;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/14 19:00
* EMail:luo_shaopeng@founder.com.cn
* Description:搜索选择监听
*/
public interface ISearchSelectedListener {
/**
* @param searchModel 选择的结果
*/
void selectedResult(SearchModel searchModel);
}
package cn.com.founder.arcgislib.search.option;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/11 19:38
* EMail:luo_shaopeng@founder.com.cn
* Description:搜索
*/
public interface IArcGisSearchOption {
}
package cn.com.founder.arcgislib.source;
import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:06
* EMail:luo_shaopeng@founder.com.cn
* Description:Activity Context
*/
public class ActivitySource extends Source implements LifecycleOwner {
private Activity activity;
public ActivitySource (Activity activity){
this.activity = activity;
}
@Override
public Context getContext() {
return activity;
}
@NonNull
@Override
public Lifecycle getLifecycle() {
return null;
}
}
package cn.com.founder.arcgislib.source;
import android.content.Context;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:07
* EMail:luo_shaopeng@founder.com.cn
* Description:Context
*/
public class ContextSource extends Source {
private Context context;
public ContextSource(Context context){
this.context = context;
}
@Override
public Context getContext() {
return context;
}
}
package cn.com.founder.arcgislib.source;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:09
* EMail:luo_shaopeng@founder.com.cn
* Description:Fragment Context
*/
public class FragmentSource extends Source{
private Fragment fragment;
public FragmentSource (Fragment fragment){
this.fragment = fragment;
}
@Override
public Context getContext() {
return fragment.getActivity();
}
}
package cn.com.founder.arcgislib.source;
import android.app.AppOpsManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import androidx.annotation.RequiresApi;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:01
* EMail:luo_shaopeng@founder.com.cn
* Description:全局最基层类
*/
public abstract class Source {
/**
* @return Context
*/
public abstract Context getContext();
/**
* 版本
*/
private int mTargetSdkVersion;
/**
* 包名
*/
private String mPackageName;
/**
* 包名管理
*/
private PackageManager mPackageManager;
/**
* app管理
*/
private AppOpsManager mAppOpsManager;
/**
* 通知
*/
private NotificationManager mNotificationManager;
/**
* @return 获取版本
*/
public int getTargetSdkVersion() {
if (mTargetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
mTargetSdkVersion = getContext().getApplicationInfo().targetSdkVersion;
}
return mTargetSdkVersion;
}
/**
* @return 获取包名
*/
public String getPackageName() {
if (mPackageName == null) {
mPackageName = getContext().getApplicationContext().getPackageName();
}
return mPackageName;
}
private PackageManager getPackageManager() {
if (mPackageManager == null) {
mPackageManager = getContext().getPackageManager();
}
return mPackageManager;
}
/**
* @return app
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
private AppOpsManager getAppOpsManager() {
if (mAppOpsManager == null) {
mAppOpsManager = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
}
return mAppOpsManager;
}
/**
* @return 通知
*/
private NotificationManager getNotificationManager() {
if (mNotificationManager == null) {
mNotificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
}
return mNotificationManager;
}
}
package cn.com.founder.arcgislib.source;
import android.content.Context;
import androidx.fragment.app.Fragment;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:13
* EMail:luo_shaopeng@founder.com.cn
* Description:androidx Fragment Context
*/
public class XFragmentSource extends Source{
private Fragment fragment;
public XFragmentSource (Fragment fragment){
this.fragment = fragment;
}
@Override
public Context getContext() {
return fragment.getContext();
}
}
package cn.com.founder.arcgislib.utils;
import android.content.Context;
import android.util.DisplayMetrics;
/**
* 导航屏幕工具
*/
public class DensityUtil {
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 根据手机的分辨率从 px(像素) 的单位 转成为 dp
*/
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
/**
* 将sp值转换为px值,保证文字大小不变
*
* @param spValue
* (DisplayMetrics类中属性scaledDensity)
* @return
*/
public static int sp2px(Context context, float spValue) {
final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (spValue * fontScale + 0.5f);
}
public static int getScreenWidth(Context context){
DisplayMetrics dm = context.getResources().getDisplayMetrics();
return dm.widthPixels;
}
public static int getScreenHeight(Context context){
DisplayMetrics dm = context.getResources().getDisplayMetrics();
return dm.heightPixels;
}
}
package cn.com.founder.arcgislib.utils;
import android.text.TextUtils;
import java.math.BigDecimal;
/**
* Created by lijingru on 2017/4/18.
*/
public class FormatUtil {
/**
* 时间的统一表示方式
* @param mm 毫秒
* @return
*/
public static String FormatTime(long mm){
int hour,minute,second;
second = (int) (mm/1000);
hour = second/3600;
minute = (second - hour*3600)/60;
second = second-hour*300-minute*60;
// if (minute< 10){
// return hour+":0"+minute;
// }
// return hour+":"+minute;
if (hour == 0 ){
return minute+" 分钟";
}
return hour+" 小时 "+minute+" 分钟";
}
/**
* 时间的统一表示方式
* @param mm 毫秒
* @return
*/
public static String FormatTime2(long mm){
int hour,minute,second;
second = (int) (mm/1000);
hour = second/3600;
minute = (second - hour*3600)/60;
second = second-hour*300-minute*60;
// if (minute< 10){
// return hour+":0"+minute;
// }
// return hour+":"+minute;
if (hour == 0 ){
return minute+"分钟";
}
return hour+"小时 "+minute+"分钟";
}
/**
* 时间的统一表示方式
* @param mm 毫秒
* @return
*/
public static String FormatTime3(long mm){
int hour,minute,second;
second = (int) (mm/1000);
hour = second/3600;
minute = (second - hour*3600)/60;
second = second-hour*300-minute*60;
// if (minute< 10){
// return hour+":0"+minute;
// }
// return hour+":"+minute;
if (hour == 0 ){
return minute+"分钟";
}
return hour+"小时"+minute+"分钟";
}
/**
* 时间的统一表示方式
* @param mm 毫秒
* @return
*/
public static String FormatTime00(long mm){
int hour,minute,second;
second = (int) (mm/1000);
hour = second/3600;
minute = (second - hour*3600)/60;
second = second-hour*300-minute*60;
if (minute< 10){
return hour+":0"+minute;
}
return hour+":"+minute;
}
/**
* 时间的表示方式
* @param mm 毫秒
* @return XX分钟
*/
public static int FormatTimeToMinute(long mm){
int hour,minute,second;
second = (int) (mm/1000);
minute = second/60;
return minute;
}
/**
* 距离的KM表示方式
* @return
*/
public static String FormatDistByKM(long ulDist) {
String strdist = null;
int ulDistanceResult = 0;
/* 避免显示出1.0公里、2.0公里、9.0公里等 */
if (ulDist / 100 * 100 % 1000 == 0) {
strdist = ulDist / 1000 + "";
} else {
// ulDist = (ulDist ) /100 * 100;
/* sprintf函数会自动四舍五入*/
float fDistanceResult = (float) ulDist / (float) 1000;
BigDecimal org = new BigDecimal(fDistanceResult);
org = org.setScale(1, BigDecimal.ROUND_HALF_UP);
fDistanceResult = org.floatValue();
if (fDistanceResult * 10 % 10 == 0) {
strdist = (int) fDistanceResult + "";
} else {
strdist = fDistanceResult + "";
}
}
return strdist;
}
public static String FormatDistKm(long ulDist){
String strdist = FormatDist(ulDist);
strdist = strdist.replace("米","m");
strdist = strdist.replace("公里","Km");
return strdist;
}
/**
* 距离的公里表示方式
* @return
*/
public static String FormatDistOnKM(long ulDist) {
String strdist = null;
int ulDistanceResult = 0;
if (ulDist < 10) {
strdist = "0.1";
} else if (ulDist < 1000) {
ulDistanceResult = Math.round((float)ulDist / 10) * 10;
if (ulDistanceResult == 1000) {
strdist = "1";
}else {
strdist = "0." + ulDistanceResult/100;
}
} else if(ulDist < 100000) {
/* 避免显示出1.0公里、2.0公里、9.0公里等 */
if (ulDist / 100 * 100 % 1000 == 0) {
strdist = ulDist / 1000 + "";
} else {
// ulDist = (ulDist ) /100 * 100;
/* sprintf函数会自动四舍五入*/
float fDistanceResult = (float) ulDist / (float) 1000;
BigDecimal org = new BigDecimal(fDistanceResult);
org = org.setScale(1, BigDecimal.ROUND_HALF_UP);
fDistanceResult = org.floatValue();
if (fDistanceResult * 10 % 10 == 0) {
strdist = (int) fDistanceResult + "";
} else {
strdist = fDistanceResult + "";
}
}
} else {
ulDistanceResult = Math.round((float)ulDist / 1000);
if (ulDistanceResult > 9999) {
ulDistanceResult = 9999;
}
strdist = ulDistanceResult + "";
}
return strdist;
}
/**
* 距离的统一表示方式
* @return
*/
public static String FormatDist(long ulDist) {
String strdist = null;
int ulDistanceResult = 0;
if (ulDist == 0)
ulDist = 1;
if (ulDist < 10) {
strdist = ulDist + "米";
} else if (ulDist < 1000) {
ulDistanceResult = Math.round((float)ulDist / 10) * 10;
if (ulDistanceResult == 1000) {
strdist = "1公里";
}else {
strdist = ulDistanceResult + "米";
}
} else if (ulDist < 100000) {
strdist = inOneAndHundredKM(ulDist);
} else {
strdist = moreHundredKM(ulDist);
}
return strdist;
}
// /**
// * 距离的统一表示方式
// * @return
// */
// public static Tuple.TwoTuple FormatDistForT(long ulDist) {
// Tuple.TwoTuple tuple = null;
// String strdist = null;
// String danwei = null;
// int ulDistanceResult = 0;
// if (ulDist < 10) {
// strdist = ulDist+"";
// danwei = "米";
// } else if (ulDist < 1000) {
// ulDistanceResult = Math.round((float)ulDist / 10) * 10;
// if (ulDistanceResult == 1000) {
// strdist = "1";
// danwei = "公里";
// }else {
// strdist = ulDistanceResult + "";
// danwei = "米";
// }
// } else if (ulDist < 100000) {
// strdist = inOneAndHundredKM(ulDist);
// strdist = strdist.replace("公里","");
// danwei = "公里";
// } else {
// strdist = moreHundredKM(ulDist);
// strdist = strdist.replace("公里","");
// danwei = "公里";
// }
// tuple = new Tuple.TwoTuple(strdist,danwei);
// return tuple;
// }
/**
* 大于1公里小于100公里的距离格式化
* @return
*/
public static String inOneAndHundredKM(long ulDist){
String strdist;
/* 避免显示出1.0公里、2.0公里、9.0公里等 */
if (ulDist / 100 * 100 % 1000 == 0) {
strdist = ulDist / 1000 + "公里";
} else {
// ulDist = (ulDist ) /100 * 100;
/* sprintf函数会自动四舍五入*/
float fDistanceResult = (float) ulDist / (float) 1000;
BigDecimal org = new BigDecimal(fDistanceResult);
org = org.setScale(1, BigDecimal.ROUND_HALF_UP);
fDistanceResult = org.floatValue();
if (fDistanceResult * 10 % 10 == 0) {
strdist = (int) fDistanceResult + "公里";
} else {
strdist = fDistanceResult + "公里";
}
}
return strdist;
}
/**
* 大于100公里的距离格式化
* @return
*/
public static String moreHundredKM(long ulDist){
String strdist;
int ulDistanceResult = Math.round((float)ulDist / 1000);
if (ulDistanceResult > 9999) {
ulDistanceResult = 9999;
}
strdist = ulDistanceResult + "公里";
return strdist;
}
/**
* 格式化周期Str
*
* @param week
* @return
*/
public static String FormatWeek(String week) {
String pushDates = "";
if (!TextUtils.isEmpty(week)){
if (week.equals("1|2|3|4|5")) {
pushDates = "工作日";
} else if (week.equals("6|7")) {
pushDates = "周末";
} else if (week.equals("1|2|3|4|5|6|7")) {
pushDates = "每天";
} else {
String str = week;
str = str.replace("1", "一");
str = str.replace("2", "二");
str = str.replace("3", "三");
str = str.replace("4", "四");
str = str.replace("5", "五");
str = str.replace("6", "六");
str = str.replace("7", "日");
str = str.replace("|", ",");
pushDates = "周" + str;
}
}
return pushDates;
}
}
package cn.com.founder.arcgislib.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/18 11:27
* EMail:luo_shaopeng@founder.com.cn
* Description:转化工具类
*/
public class GpsUtil {
private final static double a = 6378245.0;
private final static double pi = 3.1415926535897932384626;
private final static double ee = 0.00669342162296594323;
/**
* 计算地球上任意两点(经纬度)距离
*
* @param lat1 第一点纬度
* @param lng1 第一点经度
* @param lat2 第二点纬度
* @param lng2 第二点经度
* @return 返回距离 单位:米
*/
public static double distance(double lat1, double lng1, double lat2, double lng2) {
double a, b, R;
R = 6378137; // 地球半径
lat1 = lat1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
a = lat1 - lat2;
b = (lng1 - lng2) * Math.PI / 180.0;
double d;
double sa2, sb2;
sa2 = Math.sin(a / 2.0);
sb2 = Math.sin(b / 2.0);
d = 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
return d;
}
/**
* Description: WGS-84 to GCJ-02 <BR>
*
* @param latitude 纬度
* @param longitude 经度
* @return [纬度,经度]
*/
public static double[] toGCJ02Point(double latitude, double longitude) {
double[] dev = calDev(latitude, longitude);
double retLat = latitude + dev[0];
double retLon = longitude + dev[1];
return new double[]{retLat, retLon};
}
/**
* Description: WGS-84 to GCJ-02 <BR>
*
* @param latitude 纬度
* @param longitude 经度
* @param scale 经纬度保留小数位数
* @return [纬度,经度]
* @author dsn
* @date 2017年10月24日 下午2:09:27
* @version 1.0
*/
public static double[] toGCJ02Point(double latitude, double longitude, int scale) {
double[] dev = calDev(latitude, longitude);
double retLat = latitude + dev[0];
double retLon = longitude + dev[1];
return new double[]{new BigDecimal(retLat).setScale(scale, RoundingMode.DOWN).doubleValue(),
new BigDecimal(retLon).setScale(scale, RoundingMode.DOWN).doubleValue()};
}
/**
* Description:GCJ-02 to WGS-84 <BR>
*
* @param latitude 纬度
* @param longitude 经度
* @return [纬度,经度]
*/
public static double[] toWGS84Point(double latitude, double longitude) {
double[] dev = calDev(latitude, longitude);
double retLat = latitude - dev[0];
double retLon = longitude - dev[1];
dev = calDev(retLat, retLon);
retLat = latitude - dev[0];
retLon = longitude - dev[1];
return new double[]{retLat, retLon};
}
private static double[] calDev(double wgLat, double wgLon) {
if (isOutOfChina(wgLat, wgLon)) {
return new double[]{0, 0};
}
double dLat = calLat(wgLon - 105.0, wgLat - 35.0);
double dLon = calLon(wgLon - 105.0, wgLat - 35.0);
double radLat = wgLat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
return new double[]{dLat, dLon};
}
private static boolean isOutOfChina(double lat, double lon) {
if (lon < 72.004 || lon > 137.8347)
return true;
if (lat < 0.8293 || lat > 55.8271)
return true;
return false;
}
private static double calLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
return ret;
}
private static double calLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
return ret;
}
}
package cn.com.founder.arcgislib.utils;
import android.text.TextUtils;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/13 17:16
* EMail:luo_shaopeng@founder.com.cn
* Description:gson
*/
public class GsonUtil {
private static Gson gson = null;
static {
if (gson == null) {
gson = new Gson();
}
}
private GsonUtil() {
}
/**
* 转成json
*
* @param object
* @return
*/
public static String gsonString(Object object) {
String gsonString = null;
if (gson != null) {
gsonString = gson.toJson(object);
}
return gsonString;
}
/**
* 转成bean
*
* @param gsonString
* @param cls
* @return
*/
public static <T> T gsonToBean(String gsonString, Class<T> cls) {
T t = null;
if (gson != null) {
t = gson.fromJson(gsonString, cls);
}
return t;
}
/**
* 转成list
* 泛型在编译期类型被擦除导致报错
* @param gsonString
* @param cls
* @return
*/
public static <T> List<T> gsonToList(String gsonString, Class<T> cls) {
List<T> list = null;
if (gson != null) {
list = gson.fromJson(gsonString, new TypeToken<List<T>>() {
}.getType());
}
return list;
}
/**
* 转成list
* 解决泛型问题
* @param json
* @param cls
* @param <T>
* @return
*/
public static <T> List<T> jsonToList(String json, Class<T> cls) {
Gson gson = new Gson();
List<T> list = new ArrayList<T>();
JsonArray array = new JsonParser().parse(json).getAsJsonArray();
for(final JsonElement elem : array){
list.add(gson.fromJson(elem, cls));
}
return list;
}
/**
* 转成list中有map的
*
* @param gsonString
* @return
*/
public static <T> List<Map<String, T>> gsonToListMaps(String gsonString) {
List<Map<String, T>> list = null;
if (gson != null) {
list = gson.fromJson(gsonString,
new TypeToken<List<Map<String, T>>>() {
}.getType());
}
return list;
}
/**
* 转成map的
*
* @param gsonString
* @return
*/
public static <T> Map<String, T> gsonToMaps(String gsonString) {
Map<String, T> map = null;
if (gson != null) {
map = gson.fromJson(gsonString, new TypeToken<Map<String, T>>() {
}.getType());
}
return map;
}
/**
* 按章节点得到相应的内容
* @param jsonString json字符串
* @param note 节点
* @return 节点对应的内容
*/
public static String getNoteJsonString(String jsonString,String note){
if(TextUtils.isEmpty(jsonString)){
throw new RuntimeException("json字符串");
}
if(TextUtils.isEmpty(note)){
throw new RuntimeException("note标签不能为空");
}
JsonElement element = new JsonParser().parse(jsonString);
if(element.isJsonNull()){
throw new RuntimeException("得到的jsonElement对象为空");
}
return element.getAsJsonObject().get(note).toString();
}
/**
* 按照节点得到节点内容,然后传化为相对应的bean数组
* @param jsonString 原json字符串
* @param note 节点标签
* @param beanClazz 要转化成的bean class
* @return 返回bean的数组
*/
public static <T> List<T> parserJsonToArrayBeans(String jsonString,String note,Class<T> beanClazz){
String noteJsonString = getNoteJsonString(jsonString,note);
return parserJsonToArrayBeans(noteJsonString,beanClazz);
}
/**
* 按照节点得到节点内容,转化为一个数组
* @param jsonString json字符串
* @param beanClazz 集合里存入的数据对象
* @return 含有目标对象的集合
*/
public static <T> List<T> parserJsonToArrayBeans(String jsonString,Class<T> beanClazz){
if(TextUtils.isEmpty(jsonString)){
throw new RuntimeException("json字符串为空");
}
JsonElement jsonElement = new JsonParser().parse(jsonString);
if(jsonElement.isJsonNull()){
throw new RuntimeException("得到的jsonElement对象为空");
}
if(!jsonElement.isJsonArray()){
throw new RuntimeException("json字符不是一个数组对象集合");
}
JsonArray jsonArray = jsonElement.getAsJsonArray();
List<T> beans = new ArrayList<T>();
for (JsonElement jsonElement2: jsonArray) {
T bean = new Gson().fromJson(jsonElement2, beanClazz);
beans.add(bean);
}
return beans;
}
/**
* 把相对应节点的内容封装为对象
* @param jsonString json字符串
* @param clazzBean 要封装成的目标对象
* @return 目标对象
*/
public static <T> T parserJsonToArrayBean(String jsonString,Class<T> clazzBean){
if(TextUtils.isEmpty(jsonString)){
throw new RuntimeException("json字符串为空");
}
JsonElement jsonElement = new JsonParser().parse(jsonString);
if(jsonElement.isJsonNull()){
throw new RuntimeException("json字符串为空");
}
if(!jsonElement.isJsonObject()){
throw new RuntimeException("json不是一个对象");
}
return new Gson().fromJson(jsonElement, clazzBean);
}
/**
* 按照节点得到节点内容,转化为一个数组
* @param jsonString json字符串
* @param note json标签
* @param clazzBean 集合里存入的数据对象
* @return 含有目标对象的集合
*/
public static <T> T parserJsonToArrayBean(String jsonString,String note,Class<T> clazzBean){
String noteJsonString = getNoteJsonString(jsonString, note);
return parserJsonToArrayBean(noteJsonString, clazzBean);
}
/**
* 把bean对象转化为json字符串
* @param obj bean对象
* @return 返回的是json字符串
*/
public static String toJsonString(Object obj){
if(obj!=null){
return new Gson().toJson(obj);
}else{
throw new RuntimeException("对象不能为空");
}
}
}
package cn.com.founder.arcgislib.utils;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/11 20:27
* EMail:luo_shaopeng@founder.com.cn
* Description:toDo
*/
public class KeyboardUtil {
/**
* 显示键盘
*/
public static void showKeyboard(final View view) {
view.requestFocus();
InputMethodManager inputManager =
(InputMethodManager) view.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(view, 0);
}
/**
* 打开软键盘
*
* @param mEditText 输入框
* @param mContext 上下文
*/
public static void openKeybord(EditText mEditText, Context mContext) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
/**
* 关闭隐藏键盘
*/
public static void hideKeyboard(final View view) {
InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}
package cn.com.founder.arcgislib.utils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.widget.Toast;
import com.yanzhenjie.permission.AndPermission;
import java.util.List;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/3/22 0022 18:00
* EMail:luo_shaopeng@founder.com.cn
* Description:权限工具类
*/
public class PermissionUtil {
/**
* 请求权限
* @param requestPermissionCode 总是拒绝后提示用户去设置
* @param listener 权限申请监听
* @param permissionGroup 权限
*/
@SuppressLint("WrongConstant")
public static void requestPermission(Context context, int requestPermissionCode, final PermissionQuestListener listener, final String... permissionGroup) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (AndPermission.hasPermissions(context, permissionGroup)) {
listener.onGranted();
return;
}
// 没有权限,申请权限
AndPermission.with(context)
.runtime()
.permission(permissionGroup)
.onGranted(data -> {
if (listener != null){
listener.onGranted();
}
})
.onDenied(data -> {
if (AndPermission.hasAlwaysDeniedPermission(context, permissionGroup)) {
Toast.makeText(context,"定位权限获取失败",Toast.LENGTH_LONG).show();
} else {
//拒绝后重复请求
requestPermission(context,requestPermissionCode,listener, permissionGroup);
}
})
.start();
} else {
listener.onGranted();
}
}
/**
* 权限申请监听
*/
public interface PermissionQuestListener {
/**
* 允许获得权限后操作
*/
void onGranted();
/**
* 拒绝权限后操作
*
* @param data 权限列表
*/
void onDenied(List<String> data);
/**
* 总是拒绝后不再提示信息
*
* @return 权限
*/
String onAlwaysDenied();
}
}
package cn.com.founder.arcgislib.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import cn.com.founder.arcgislib.common.Variable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 17:35
* EMail:luo_shaopeng@founder.com.cn
* Description:工具类
*/
public class ToolUtil {
/**
* 判断是否打开网络
* @param context
* @return
*/
public static boolean isNetWorkAvailable(Context context){
boolean isAvailable = false ;
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if(networkInfo!=null && networkInfo.isAvailable()){
isAvailable = true;
}
return isAvailable;
}
/**
* @param context 上下文
* @param value
* @return
*/
public static int valueToSp(Context context, int value){
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value, context.getResources().getDisplayMetrics());
}
/**
* @param num 数值
* @return 保留两位小数的String
*/
public static String forMatDouble(double num){
BigDecimal b = new BigDecimal(num);
double df = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return df+"";
}
/**
* @param length 数值
* @param type {@link Variable.Measure}
* @return 距离长度转换
*/
public static double lengthChange(double length, Variable.Measure type){
if(type== Variable.Measure.M) return length;
if(type==Variable.Measure.KM || type==Variable.Measure.KIM)
return mToKm(length);
return 0;
}
public static double mToKm(double length){
return length/1000;
}
/**
* @param type {@link Variable.Measure}
* @return String
*/
public static String lengthEnameToCname(Variable.Measure type){
switch (type){
case M:
return "米";
case KM:
return "千米";
case KIM:
return "公里";
case M2:
return "平方米";
case KM2:
return "平方千米";
case HM2:
return "公顷";
case A2:
return "亩";
}
return null;
}
/**
* @param area 数值
* @param type {@link Variable.Measure}
* @return 区域计算
*/
public static double areaChange(double area, Variable.Measure type){
switch (type){
case M2:
return area;
case KM2:
return m2ToKm2(area);
case HM2:
return m2ToHm2(area);
case A2:
return m2ToA2(area);
}
return 0;
}
private static double m2ToKm2(double area){
return area/1000;
}
private static double m2ToHm2(double area){
return area/10000;
}
private static double m2ToA2(double area){
return area/666.67;
}
/**
* 获取 DisplayMetrics
*
* @return
*/
private static DisplayMetrics getDisplayMetrics(Context context) {
return context.getResources().getDisplayMetrics();
}
/**
* 把以 dp 为单位的值,转化为以 px 为单位的值
*
* @param dpValue 以 dp 为单位的值
* @return px value
*/
public static int dpToPx(Context context, int dpValue) {
return (int) (dpValue * getDisplayMetrics(context).density + 0.5f);
}
/**
* 获取屏幕宽度
*
* @return
*/
public static int getScreenWidth(Context context) {
return getDisplayMetrics(context).widthPixels;
}
/**
* 获取屏幕高度
*
* @return
*/
public static int getScreenHeight(Context context) {
int screenHeight = getDisplayMetrics(context).heightPixels;
return screenHeight;
}
/**
* 动态显示软键盘
*
*/
public static void showSoftInput(Context context, final View view) {
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
inputMethodManager.showSoftInput(view, 0);
}
}, 200);
}
/**
* 动态隐藏软键盘
*
*/
public static void hideSoftInput(Context context, final View view) {
try {
InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
} catch (Exception e) {
}
}
/**
* 根据行读取内容
* @return List<String>
*/
public static List<String> getFileContent(Context context,String filePath) {
List<String> newList=new ArrayList<>();
try {
File file = new File(filePath);
int count = 0;//初始化 key值
if (file.isFile() && file.exists()) {//文件存在
InputStreamReader isr = new InputStreamReader(new FileInputStream(file));
BufferedReader br = new BufferedReader(isr);
String lineTxt = null;
while ((lineTxt = br.readLine()) != null) {
if (!"".equals(lineTxt)) {
String reds = lineTxt.split("\\+")[0]; //java 正则表达式
newList.add(count, reds);
count++;
}
}
isr.close();
br.close();
}else {
Toast.makeText(context,"找不到指定文件",Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return newList;
}
}
package cn.com.founder.arcgislib.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 15:47
* EMail:luo_shaopeng@founder.com.cn
* Description:BaseView
*/
public class ArcGisBaseView extends FrameLayout {
public ArcGisBaseView(@NonNull Context context) {
this(context, null, 0);
}
public ArcGisBaseView(@NonNull Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public ArcGisBaseView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
addView(new ArcGisMapView(context,attrs,defStyleAttr));
}
}
package cn.com.founder.arcgislib.view;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.esri.arcgisruntime.data.ServiceFeatureTable;
import com.esri.arcgisruntime.geometry.GeometryEngine;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.PointCollection;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.layers.FeatureLayer;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import java.util.ArrayList;
import java.util.List;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.widget.cluster.ClusterLayer;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2020/2/16 15:48
* EMail:luo_shaopeng@founder.com.cn
* Description:点聚合
*/
public class ArcGisClusterView extends LinearLayout implements View.OnClickListener {
protected static ArcGisClusterView instance;
/**
* {@link Context}
*/
private Context mContext;
/**
* 聚合根布局
*/
private LinearLayout mClusterTotalLayout;
/**
* 聚合图片
*/
protected ImageView mClusterIv;
/**
* {@link ArcGisMapView}
*/
private ArcGisMapView mArcGisMapView;
/**
* {@link MapView}
*/
private MapView mMapView;
/**
* {@link GraphicsOverlay}
*/
private GraphicsOverlay graphicsOverlay;
/**
* {@link FeatureLayer}
*/
private FeatureLayer featureLayer;
/**
* {@link ClusterLayer}
*/
private ClusterLayer clusterLayer;
/**
* 是否清楚图层
*/
private boolean isClean;
/**
* 模拟点集合
*/
private PointCollection mPointCollection;
/**
* 实际数据源
*/
private List<Point> pointList = new ArrayList<>();
public ArcGisClusterView(Context context, ArcGisMapView arcGisMapView) {
this(context);
this.mContext = context;
this.mArcGisMapView = arcGisMapView;
this.mMapView = mArcGisMapView.getMapView();
mPointCollection = new PointCollection(SpatialReference.create(4326));
graphicsOverlay = new GraphicsOverlay();
mMapView.getGraphicsOverlays().add(graphicsOverlay);
// addFeatureLayer();
}
private ArcGisClusterView(Context context) {
this(context, null, 0);
}
private ArcGisClusterView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
private ArcGisClusterView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.layout_cluster, this);
instance = this;
mClusterTotalLayout = findViewById(R.id.cluster_layout);
mClusterIv = findViewById(R.id.cluster_iv);
mClusterIv.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if(isClean){
graphicsOverlay.setVisible(false);
clusterLayer.setGraphicVisible(false);
}else{
// initRamdData();
boolean isEmpty = pointList.size() == 0;
if(isEmpty){
Toast.makeText(mContext,"暂无数据源",Toast.LENGTH_LONG).show();
return;
}
graphicsOverlay.setVisible(true);
if(clusterLayer == null){
clusterLayer = new ClusterLayer(mMapView, graphicsOverlay, mContext);
}
clusterLayer.setGraphicVisible(true);
}
isClean = !isClean;
// featureLayer.setVisible(false);
// ClusterFeatureLayer clusterFeatureLayer = new ClusterFeatureLayer(
// mMapView, featureLayer, mContext, 150
// );
// clusterFeatureLayer.setGraphicVisible(true);
}
private void addFeatureLayer() {
featureLayer = new FeatureLayer(new ServiceFeatureTable(
"https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0"));
mMapView.getMap().getOperationalLayers().add(featureLayer);
}
/**
*设置数据源
*/
public void setClusterData(List<Point> points){
boolean isEmpty = points == null || points.isEmpty();
if(isEmpty){
Toast.makeText(mContext,"暂无数据源",Toast.LENGTH_LONG).show();
return;
}
pointList.clear();
pointList.addAll(points);
for (Point point: pointList) {
Point graPoint= (Point) GeometryEngine.project(point,mMapView.getSpatialReference());
Graphic gra1 = new Graphic(graPoint, simpleMarkerSymbol);
graphicsOverlay.getGraphics().add(gra1);
}
}
/**
* 模拟数据源
*/
private void initRamdData() {
graphicsOverlay.getGraphics().clear();
mPointCollection.clear();
mPointCollection.add(new Point(113.935576,22.995918));
mPointCollection.add(new Point(113.959722,23.000176));
mPointCollection.add(new Point(113.97582,22.949069));
mPointCollection.add(new Point(113.952823,22.916051));
mPointCollection.add(new Point(114.019513,22.951198));
mPointCollection.add(new Point(113.876934,22.998047));
mPointCollection.add(new Point(113.909129,22.936289));
mPointCollection.add(new Point(113.847039,22.998047));
mPointCollection.add(new Point(114.114949,22.995918));
mPointCollection.add(new Point(114.047109,22.97356));
mPointCollection.add(new Point(114.066656,22.935224));
for (Point point: mPointCollection) {
Point graPoint= (Point) GeometryEngine.project(point,mMapView.getSpatialReference());
Graphic gra1 = new Graphic(graPoint, simpleMarkerSymbol);
graphicsOverlay.getGraphics().add(gra1);
}
//随机点
// for (int i = 0; i < 1000; i++) {
// double lat = Math.random() + 23.02067;
// double lon = Math.random() + 113.75179;
// Point point = new Point(lon, lat, SpatialReference.create(4326));
// Point graPoint= (Point) GeometryEngine.project(point,mMapView.getSpatialReference());
// Graphic gra1 = new Graphic(graPoint, simpleMarkerSymbol);
// graphicsOverlay.getGraphics().add(gra1);
// }
}
SimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.BLACK, 0);
/**
* @param isShow boolean-是否显示聚合布局
* 默认显示
*/
public void setShowClusterLayout(boolean isShow) {
if (isShow) {
mClusterTotalLayout.setVisibility(VISIBLE);
} else {
mClusterTotalLayout.setVisibility(GONE);
}
}
/**
* @param location {@link Variable.ViewLocation } ClusterView显示位置
*/
public void setClusterViewLocation(Variable.ViewLocation location) {
switch (location) {
case LEFT_TOP:
mClusterTotalLayout.setGravity(Gravity.LEFT | Gravity.TOP);
break;
case RIGHT_TOP:
mClusterTotalLayout.setGravity(Gravity.RIGHT | Gravity.TOP);
break;
case CENTER:
mClusterTotalLayout.setGravity(Gravity.CENTER);
break;
case LEFT_BOTTOM:
mClusterTotalLayout.setGravity(Gravity.LEFT | Gravity.BOTTOM);
break;
case RIGHT_BOTTOM:
mClusterTotalLayout.setGravity(Gravity.RIGHT | Gravity.BOTTOM);
break;
}
}
/**
* @param clusterImage int(资源ID)-聚合图片
*/
public void setClusterImage(int clusterImage) {
mClusterIv.setImageDrawable(getResources().getDrawable(clusterImage));
}
}
package cn.com.founder.arcgislib.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.compass.listener.IOnClickListener;
import cn.com.founder.arcgislib.compass.listener.IRotationListener;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/8 10:17
* EMail:luo_shaopeng@founder.com.cn
* Description:罗盘
*/
public class ArcGisMapCompassView extends LinearLayout implements View.OnClickListener, ArcGisMapView.MyTouchCompassListener {
/**
* 罗盘根布局
*/
private LinearLayout mCompassTotalLayout;
/**
* 罗盘图片
*/
private ImageView mCompassIv;
/**
* {@link ArcGisMapView}
*/
private ArcGisMapView mArcGisMapView;
/**
* {@link IOnClickListener}
*/
private IOnClickListener mIOnClickListener;
/**
* 罗盘旋转监听
*/
private IRotationListener mIRotationListener;
/**
* 是否显示罗盘
*/
private boolean isShowCompass = true;
@SuppressLint("ClickableViewAccessibility")
public ArcGisMapCompassView(Context context, ArcGisMapView arcGisMapView) {
this(context);
this.mArcGisMapView = arcGisMapView;
mArcGisMapView.setMyTouchCompassListener(this);
}
private ArcGisMapCompassView(Context context) {
this(context, null, 0);
}
private ArcGisMapCompassView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
private ArcGisMapCompassView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.layout_compass, this);
mCompassTotalLayout = findViewById(R.id.compasss_layout);
mCompassIv = findViewById(R.id.compasss_iv);
mCompassIv.setOnClickListener(this);
}
/**
* @param isShow boolean-是否显示罗盘布局
* 默认显示
*/
public void setShowCompassLayout(boolean isShow) {
isShowCompass = isShow;
if (isShow) {
mCompassTotalLayout.setVisibility(VISIBLE);
} else {
mCompassTotalLayout.setVisibility(GONE);
}
}
/**
* @param location {@link Variable.ViewLocation } CompassView显示位置
*/
public void setCompassViewLocation(Variable.ViewLocation location) {
switch (location) {
case LEFT_TOP:
mCompassTotalLayout.setGravity(Gravity.LEFT | Gravity.TOP);
break;
case RIGHT_TOP:
mCompassTotalLayout.setGravity(Gravity.RIGHT | Gravity.TOP);
break;
case CENTER:
mCompassTotalLayout.setGravity(Gravity.CENTER);
break;
case LEFT_BOTTOM:
mCompassTotalLayout.setGravity(Gravity.LEFT | Gravity.BOTTOM);
break;
case RIGHT_BOTTOM:
mCompassTotalLayout.setGravity(Gravity.RIGHT | Gravity.BOTTOM);
break;
}
}
/**
* @param compassImage int(资源ID)-罗盘图片
*/
public void setCompassImage(int compassImage) {
mCompassIv.setImageDrawable(getResources().getDrawable(compassImage));
}
public void setIOnClik(IOnClickListener iOnClickListener){
this.mIOnClickListener = iOnClickListener;
}
/**
* @param iRotationListener 地图旋转监听
*/
public void setIRotationListener(IRotationListener iRotationListener) {
this.mIRotationListener = iRotationListener;
}
@Override
public void onClick(View view) {
this.setVisibility(View.GONE);
mArcGisMapView.getMapView().setViewpointRotationAsync(0);
if(mIOnClickListener != null){
mIOnClickListener.onClick(view);
}
}
@Override
public void onUp(Variable.TouchUp touchUp, MotionEvent motionEvent) {
if(touchUp == Variable.TouchUp.RORATE){
if(mIRotationListener != null){
mIRotationListener.iRotationAngleListener();
}
}
}
@Override
public void onRotate(double rotationAngle) {
if(isShowCompass){
if (rotationAngle != 0){
mCompassTotalLayout.setVisibility(View.VISIBLE);
mCompassIv.setRotation(-(float) rotationAngle);
postInvalidate();
}else{
mCompassTotalLayout.setVisibility(View.GONE);
}
}
}
}
\ No newline at end of file
package cn.com.founder.arcgislib.view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.geometry.Envelope;
import com.esri.arcgisruntime.geometry.SpatialReference;
import com.esri.arcgisruntime.layers.ArcGISTiledLayer;
import com.esri.arcgisruntime.mapping.ArcGISMap;
import com.esri.arcgisruntime.mapping.Basemap;
import com.esri.arcgisruntime.mapping.Viewpoint;
import com.esri.arcgisruntime.mapping.view.BackgroundGrid;
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.mapping.view.WrapAroundMode;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.constants.Constants;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 14:11
* EMail:luo_shaopeng@founder.com.cn
* Description:地图封装
*/
public class ArcGisMapView extends LinearLayout {
/**
* MapView
*/
private MapView mMapView;
/**
* 地图操作图层(点,线,面)
*/
private GraphicsOverlay mLocationGraphicsOverlay;
/**
* 搜索地图操作图层(点)
*/
private GraphicsOverlay mSearchGraphicsOverlay;
/**
* 导航地图操作图层(点,线)
*/
private GraphicsOverlay mNaviGraphicsOverlay;
/**
* 导航地图操作图层(点)
*/
private GraphicsOverlay mRouteMarkerGraphicsOverlay;
/**
* 长按事件拦截
*/
private MotionEvent mLongPressEvent;
/**
* 旋转事件拦截
*/
private MotionEvent mRotateEvent;
public ArcGisMapView(Context context) {
this(context, null);
}
public ArcGisMapView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public ArcGisMapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
//arcgis 开发者证书
ArcGISRuntimeEnvironment.setLicense(Constants.BASE_MAP_RUNTIME);
inflate(context, R.layout.layout_arc_gis_map, this);
mMapView = findViewById(R.id.founder_arc_gis_mapview);
createMap();
}
/**
* 创建地图
*/
@SuppressLint("ClickableViewAccessibility")
private void createMap() {
//网络图层地址
ArcGISTiledLayer arcGISTiledLayer = new ArcGISTiledLayer(Constants.BASE_MAP_SERVER_URL);
Basemap basemap = new Basemap(arcGISTiledLayer);
ArcGISMap arcGISMap = new ArcGISMap(basemap);
// //最大缩放级别
// arcGISMap.setMaxScale(8);
//去掉水印
mMapView.setAttributionTextVisible(false);
BackgroundGrid mainBackgroundGrid = new BackgroundGrid();
mMapView.setBackgroundGrid(mainBackgroundGrid);
Envelope envelope = new Envelope(67.8515625, 1.58203125, 139.306640625, 56.337890625, SpatialReference.create(4326));
mMapView.setViewpoint(new Viewpoint(envelope));
mMapView.setMap(arcGISMap);
//查看地图时,无缝延展地图
mMapView.setWrapAroundMode(WrapAroundMode.ENABLE_WHEN_SUPPORTED);
// 长按放大镜可用
mMapView.setMagnifierEnabled(true);
addLocationGraphicLayers();
addSearchGraphicLayers();
addRouteMarkerGraphicLayers();
mLongPressEvent = null;
mMapView.setOnTouchListener(new ArcGisMapView.MapTouchListener(getContext().getApplicationContext(), mMapView));
mMapView.addViewpointChangedListener(visibleAreaChangedEvent -> {
if (myTouchCompassListener != null) {
myTouchCompassListener.onRotate(((MapView) visibleAreaChangedEvent.getSource()).getMapRotation());
}
});
}
private void addLocationGraphicLayers() {
// Add location layer
if (mLocationGraphicsOverlay == null) {
mLocationGraphicsOverlay = new GraphicsOverlay();
}
mLocationGraphicsOverlay.setOpacity(0.8f);
mMapView.getGraphicsOverlays().add(mLocationGraphicsOverlay);
}
private void addSearchGraphicLayers() {
// Add location layer
if (mSearchGraphicsOverlay == null) {
mSearchGraphicsOverlay = new GraphicsOverlay();
}
mSearchGraphicsOverlay.setOpacity(0.8f);
mMapView.getGraphicsOverlays().add(mSearchGraphicsOverlay);
}
private void addNaviGraphicLayers() {
// Add location layer
if (mNaviGraphicsOverlay == null) {
mNaviGraphicsOverlay = new GraphicsOverlay();
}
mNaviGraphicsOverlay.setOpacity(0.8f);
mMapView.getGraphicsOverlays().add(mNaviGraphicsOverlay);
}
private void addRouteMarkerGraphicLayers() {
// Add location layer
if (mRouteMarkerGraphicsOverlay == null) {
mRouteMarkerGraphicsOverlay = new GraphicsOverlay();
}
mRouteMarkerGraphicsOverlay.setOpacity(0.8f);
mMapView.getGraphicsOverlays().add(mRouteMarkerGraphicsOverlay);
}
protected MapView getMapView() {
return mMapView;
}
protected GraphicsOverlay getLocationGraphicsOverlay() {
return mLocationGraphicsOverlay;
}
protected GraphicsOverlay getSearchGraphicsOverlay() {
return mSearchGraphicsOverlay;
}
protected GraphicsOverlay getNaviGraphicsOverlay() {
return mSearchGraphicsOverlay;
}
protected GraphicsOverlay getRouteMarkerGraphicsOverlay() {
return mRouteMarkerGraphicsOverlay;
}
private class MapTouchListener extends DefaultMapViewOnTouchListener {
/**
* Instantiates a new DrawingMapViewOnTouchListener with the specified
* context and MapView.
*
* @param context the application context from which to get the display
* metrics
* @param mapView the MapView on which to control touch events
*/
MapTouchListener(Context context, MapView mapView) {
super(context, mapView);
}
@Override
public boolean onUp(MotionEvent motionEvent) {
if (myTouchLocationListener != null) {
if (mLongPressEvent != null) {
mLongPressEvent = null;
myTouchLocationListener.onUp(Variable.TouchUp.LONG_PRESS, motionEvent);
} else {
myTouchLocationListener.onUp(Variable.TouchUp.UP, motionEvent);
}
}
if (mRotateEvent != null && myTouchCompassListener != null) {
mRotateEvent = null;
myTouchCompassListener.onUp(Variable.TouchUp.RORATE, motionEvent);
}
return true;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
if (myTouchLocationListener != null) {
myTouchLocationListener.onSingleTap(motionEvent);
}
return super.onSingleTapConfirmed(motionEvent);
}
@Override
public void onLongPress(MotionEvent motionEvent) {
super.onLongPress(motionEvent);
mLongPressEvent = motionEvent;
if (myTouchLocationListener != null) {
myTouchLocationListener.onLongPress(motionEvent);
}
}
@Override
public boolean onRotate(MotionEvent motionEvent, double rotationAngle) {
super.onRotate(motionEvent, rotationAngle);
mRotateEvent = motionEvent;
if (myTouchCompassListener != null) {
myTouchCompassListener.onRotate(mMapView.getMapRotation());
}
return true;
}
}
private MyTouchLocationListener myTouchLocationListener;
private MyTouchCompassListener myTouchCompassListener;
protected void setMyTouchLocationListener(MyTouchLocationListener touchListener) {
this.myTouchLocationListener = touchListener;
}
protected void setMyTouchCompassListener(MyTouchCompassListener touchListener) {
this.myTouchCompassListener = touchListener;
}
/**
* 位置触摸监听类
*/
interface MyTouchLocationListener {
/**
* 手指抬起时
*
* @param touchUp {@link Variable.TouchUp}
* @param motionEvent 移动事件
*/
void onUp(Variable.TouchUp touchUp, MotionEvent motionEvent);
/**
* 单击
*
* @param motionEvent 移动事件
*/
void onSingleTap(MotionEvent motionEvent);
/**
* 长按
*
* @param motionEvent 移动事件
*/
void onLongPress(MotionEvent motionEvent);
}
/**
* 罗盘触摸监听类
*/
interface MyTouchCompassListener {
/**
* 手指抬起时
*
* @param touchUp {@link Variable.TouchUp}
* @param motionEvent 移动事件
*/
void onUp(Variable.TouchUp touchUp, MotionEvent motionEvent);
/**
* 旋转
*
* @param rotationAngle 旋转角度
*/
void onRotate(double rotationAngle);
}
}
package cn.com.founder.arcgislib.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.esri.arcgisruntime.mapping.view.MapView;
import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.utils.ToolUtil;
import cn.com.founder.arcgislib.zoom.listener.IZoomClickListener;
/**
* Copyright: 方正国际软件有限公司
* Author:luo_shaopeng
* Date:2019/11/4 16:55
* EMail:luo_shaopeng@founder.com.cn
* Description:自定义缩放view
*/
public class ArcGisMapZoomView extends LinearLayout implements View.OnClickListener {
/**
* 根布局
*/
private LinearLayout mZoomTotalLayout;
/**
* 父布局
*/
private LinearLayout mZoomContentLayout;
/**
* 放大布局
*/
private LinearLayout mZoomInLayout;
/**
* 放大图片
*/
private ImageView mZoomInImage;
/**
* 放大文字
*/
private TextView mZoomInTextView;
/**
* 水平分割线
*/
private TextView mSpliteLineHor;
/**
* 垂直分割线
*/
private TextView mSpliteLineVer;
/**
* 缩小布局
*/
private LinearLayout mZoomOutLayout;
/**
* 缩小图片
*/
private ImageView mZoomOutImage;
/**
* 缩小文字
*/
private TextView mZoomOutTextView;
/**
* 放大倍数
*/
private double zoomInNum = 2;
/**
* 缩小倍数
*/
private double zoomOutNum = 2;
/**
* 缩放控件点击事件监听
*/
private IZoomClickListener zoomClickListener;
/**
* MapView
*/
private MapView mMapView;
public ArcGisMapZoomView(Context context, MapView mapView) {
this(context);
this.mMapView = mapView;
}
private ArcGisMapZoomView(Context context) {
this(context, null, 0);
}
private ArcGisMapZoomView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
private ArcGisMapZoomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
inflate(context, R.layout.layout_zoom, this);
initView();
}
/**
* 初始化view
*/
private void initView() {
mZoomTotalLayout = findViewById(R.id.zoom_total_layout);
mZoomContentLayout = findViewById(R.id.zoom_content_layout);
mZoomInLayout = findViewById(R.id.zoom_in_layout);
mZoomInImage = findViewById(R.id.zoom_in_iv);
mZoomInTextView = findViewById(R.id.zoom_in_tv);
mZoomOutLayout = findViewById(R.id.zoom_out_layout);
mZoomOutImage = findViewById(R.id.zoom_out_iv);
mZoomOutTextView = findViewById(R.id.zoom_out_tv);
mZoomInLayout.setOnClickListener(this);
mZoomOutLayout.setOnClickListener(this);
}
/**
* @param isShow boolean-是否显示缩放布局
* 默认显示
*/
public void setShowZoomLayout(boolean isShow) {
if (isShow) {
mZoomTotalLayout.setVisibility(VISIBLE);
mZoomContentLayout.setVisibility(VISIBLE);
} else {
mZoomTotalLayout.setVisibility(GONE);
mZoomContentLayout.setVisibility(GONE);
}
}
/**
* @param w int-缩放布局的宽度
* 默认wrap
*/
public void setZoomWidth(int w) {
mZoomInLayout.getLayoutParams().width = ToolUtil.valueToSp(getContext(), w);
mZoomOutLayout.getLayoutParams().width = ToolUtil.valueToSp(getContext(), w);
}
/**
* @param h int-缩放布局的高度
* 默认wrap
*/
public void setZoomHeight(int h) {
mZoomInLayout.getLayoutParams().height = ToolUtil.valueToSp(getContext(), h);
mZoomOutLayout.getLayoutParams().height = ToolUtil.valueToSp(getContext(), h);
}
/**
* @param bg int(资源ID)-缩放布局的背景
* 默认带阴影布局
*/
public void setZoomBackground(int bg) {
mZoomContentLayout.setBackground(getResources().getDrawable(bg));
}
/**
* @param horizontal boolean-缩放布局是否水平方向
* 默认垂直方向
*/
public void isHorizontal(boolean horizontal) {
if (horizontal) {
mZoomContentLayout.setOrientation(HORIZONTAL);
mSpliteLineVer.setVisibility(View.GONE);
mSpliteLineHor.setVisibility(View.VISIBLE);
} else {
mZoomContentLayout.setOrientation(VERTICAL);
mSpliteLineVer.setVisibility(View.VISIBLE);
mSpliteLineHor.setVisibility(View.GONE);
}
}
/**
* @param zoomInImage int(资源ID)-放大布局图片
*/
public void setZoomInImage(int zoomInImage) {
mZoomInImage.setImageDrawable(getResources().getDrawable(zoomInImage));
}
/**
* @param zoomOutImage int(资源ID)-缩小布局图片
*/
public void setZoomOutImage(int zoomOutImage) {
mZoomOutImage.setImageDrawable(getResources().getDrawable(zoomOutImage));
}
/**
* @param showText boolean-是否显示文字
* 默认显示
*/
public void setShowText(boolean showText) {
if (showText) {
mZoomInTextView.setVisibility(View.VISIBLE);
mZoomOutTextView.setVisibility(View.VISIBLE);
} else {
mZoomInTextView.setVisibility(View.GONE);
mZoomOutTextView.setVisibility(View.GONE);
}
}
/**
* @param zoomInText String-放大布局的文字
* 默认“放大”
*/
public void setZoomInText(String zoomInText) {
if (zoomInText == null) return;
mZoomInTextView.setText(zoomInText);
}
/**
* @param zoomOutText String-缩小布局的文字
* 默认“缩小”
*/
public void setZoomOutText(String zoomOutText) {
if (zoomOutText == null) return;
mZoomOutTextView.setText(zoomOutText);
}
/**
* @param fontSize int-缩放布局的文字大小
* 默认14sp
*/
public void setFontSize(int fontSize) {
mZoomInTextView.setTextSize(fontSize);
mZoomOutTextView.setTextSize(fontSize);
}
/**
* @param fontColor int-缩放布局的文字颜色
* 默认#333333
*/
public void setFontColor(int fontColor) {
int color = getResources().getColor(fontColor);
mZoomInTextView.setTextColor(color);
mZoomOutTextView.setTextColor(color);
}
/**
* @param num int-放大倍数
* 默认2
*/
public void setZoomInNum(int num) {
zoomInNum = num;
}
/**
* @param num int-缩小倍数
* 默认2
*/
public void setZoomOutNum(int num) {
zoomOutNum = num;
}
/**
* @param zoomClickListener 缩放事件监听
*/
public void setZoomClickListener(IZoomClickListener zoomClickListener) {
this.zoomClickListener = zoomClickListener;
}
/**
* @param location {@link Variable.ViewLocation }ZoomView显示位置
*/
public void setZoomViewLocation(Variable.ViewLocation location) {
switch (location) {
case LEFT_TOP:
mZoomTotalLayout.setGravity(Gravity.LEFT | Gravity.TOP);
break;
case RIGHT_TOP:
mZoomTotalLayout.setGravity(Gravity.RIGHT | Gravity.TOP);
break;
case CENTER:
mZoomTotalLayout.setGravity(Gravity.CENTER);
break;
case LEFT_BOTTOM:
default:
mZoomTotalLayout.setGravity(Gravity.LEFT | Gravity.BOTTOM);
}
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.zoom_in_layout) {
double scale = mMapView.getMapScale();
double currScale = scale * (1.0 / zoomInNum);
mMapView.setViewpointScaleAsync(currScale);
if (zoomClickListener != null) {
zoomClickListener.zoomInClick(view, currScale);
}
} else if (view.getId() == R.id.zoom_out_layout) {
double scale = mMapView.getMapScale();
double currScale = scale * zoomInNum;
mMapView.setViewpointScaleAsync(currScale);
if (zoomClickListener != null) {
zoomClickListener.zoomInClick(view, currScale);
}
}
}
}
package cn.com.founder.arcgislib.widget.cluster;
import android.content.Context;
import android.graphics.Color;
import com.esri.arcgisruntime.geometry.Envelope;
import com.esri.arcgisruntime.geometry.Geometry;
import com.esri.arcgisruntime.geometry.Point;
import com.esri.arcgisruntime.geometry.Polygon;
import com.esri.arcgisruntime.mapping.view.Graphic;
import com.esri.arcgisruntime.mapping.view.GraphicsOverlay;
import com.esri.arcgisruntime.mapping.view.MapScaleChangedEvent;
import com.esri.arcgisruntime.mapping.view.MapScaleChangedListener;
import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.CompositeSymbol;
import com.esri.arcgisruntime.symbology.SimpleMarkerSymbol;
import com.esri.arcgisruntime.symbology.Symbol;
import com.esri.arcgisruntime.symbology.TextSymbol;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 模拟聚合
*/
public class ClusterLayer {
final private int _clusterTolerance = 300;
private double _clusterResolution;
private MapView _mapView;
private GraphicsOverlay _GraphicsOverlay;
private GraphicsOverlay _clusterGraphicsOverlay;
private List<Map<String, Object>> _clusterData;
private Context _context;
private int clusterID = 0;
ArrayList<Graphic> _clusterGraphics = new ArrayList<Graphic>();
public ClusterLayer(final MapView mapView, GraphicsOverlay GraphicsOverlay,
Context context) {
if (mapView == null || GraphicsOverlay == null) {
return;
}
this._clusterResolution = _getExtent(mapView.getVisibleArea()).getWidth()
/ mapView.getWidth();
this._mapView = mapView;
this._GraphicsOverlay = GraphicsOverlay;
this._clusterData = new ArrayList<Map<String, Object>>();
this._clusterGraphicsOverlay = new GraphicsOverlay();
this._mapView.getGraphicsOverlays().add(this._clusterGraphicsOverlay);
this._context = context;
this._clusterGraphics();
mapView.addMapScaleChangedListener(new MapScaleChangedListener() {
@Override
public void mapScaleChanged(MapScaleChangedEvent mapScaleChangedEvent) {
if (!mapView.isNavigating()) {
_clusterResolution = _getExtent(_mapView.getVisibleArea())
.getWidth() / _mapView.getWidth();
_clusterData.clear();
_clusterGraphics.clear();
_clusterGraphicsOverlay.getGraphics().clear();
_clusterGraphics();
}
}
});
}
public GraphicsOverlay getGraphicLayer() {
return this._clusterGraphicsOverlay;
}
public void setGraphicVisible(boolean visible) {
if (_clusterGraphicsOverlay != null) {
_clusterGraphicsOverlay.setVisible(visible);
}
}
public void removeGraphiclayer() {
if (_mapView != null && _clusterGraphicsOverlay != null) {
try {
this._mapView.getGraphicsOverlays().remove(_clusterGraphicsOverlay);
_clusterGraphicsOverlay.getGraphics().clear();
} catch (Exception e) {
}
}
}
public void clear() {
if (_clusterGraphicsOverlay != null) {
_clusterGraphicsOverlay.getGraphics().clear();
}
}
public ArrayList<Graphic> getGraphicsByClusterID(int id) {
ArrayList<Graphic> graphics = new ArrayList<>();
for (Graphic gra : this._clusterGraphics
) {
if (Integer.valueOf(gra.getAttributes().get("clusterID").toString()) == id) {
graphics.add(gra);
}
}
return graphics;
}
private void _clusterGraphics() {
// 遍历所有的point,判断添加到哪一个cluster中
clusterID = 0;
for (int j = 0, jl = _GraphicsOverlay.getGraphics().size(); j < jl; j++) {
Graphic graphic = this._GraphicsOverlay.getGraphics().get(j);
Point point = (Point) graphic.getGeometry();
boolean clustered = false;
for (int i = 0, il = this._clusterData.size(); i < il; i++) {
Map<String, Object> cluster = this._clusterData.get(i);
Point pointCluster = new Point((Double) cluster.get("x"),
(Double) cluster.get("y"), _mapView.getSpatialReference());
if (this._clusterTest(point, pointCluster)) {
this._clusterAddGraphic(graphic, cluster);
clustered = true;
break;
}
}
if (!clustered) {
this._clusterCreate(graphic);
}
}
this._showAllClusters();
}
private void _clusterAddGraphic(Graphic graphic, Map<String, Object> cluster) {
int count = (Integer) cluster.get("count");
Point point = (Point) graphic.getGeometry();
double xCluster = (Double) cluster.get("x");
double yCluster = (Double) cluster.get("y");
double x = (point.getX() + (xCluster * count)) / (count + 1);
double y = (point.getY() + (yCluster * count)) / (count + 1);
cluster.remove("x");
cluster.remove("y");
cluster.put("x", x);
cluster.put("y", y);
Envelope envelope = (Envelope) Geometry.fromJson(cluster.get("extent").toString());
double xMin, yMin, xMax, yMax;
xMin = envelope.getXMin();
yMin = envelope.getYMin();
xMax = envelope.getXMax();
yMax = envelope.getYMax();
// 建立extent,把所有的point都包含在cluster中
if (point.getX() < xMin) {
xMin = point.getX();
}
if (point.getX() > xMax) {
xMax = point.getX();
}
if (point.getY() < yMin) {
yMin = point.getY();
}
if (point.getY() > yMax) {
yMax = point.getY();
}
Envelope envelopeNew = new Envelope(xMin, yMin, xMax, yMax, _mapView.getSpatialReference());
cluster.remove("extent");
cluster.put("extent", envelopeNew.toJson());
count++;
cluster.remove("count");
cluster.put("count", count);
if (_clusterGraphics != null) {
_clusterGraphics.add(graphic);
}
}
private void _clusterCreate(Graphic graphic) {
_clusterGraphics.add(graphic);
Map<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("count", 1);
Point point = (Point) graphic.getGeometry();
hashMap.put("extent", new Envelope((Point) graphic.getGeometry(), 0, 0).toJson());
// hashMap.put("graphics", graphics);
hashMap.put("x", point.getX());
hashMap.put("y", point.getY());
hashMap.put("clusterID", clusterID);
graphic.getAttributes().put("clusterID", clusterID);
clusterID++;
this._clusterData.add(hashMap);
}
private boolean _clusterTest(Point point, Point pointCluster) {
double distance = (Math.sqrt(Math.pow(
(pointCluster.getX() - point.getX()), 2)
+ Math.pow((pointCluster.getY() - point.getY()), 2)) / this._clusterResolution);
return (distance <= this._clusterTolerance);
}
private void _showAllClusters() {
this._clusterGraphicsOverlay.getGraphics().clear();
for (int i = 0, il = this._clusterData.size(); i < il; i++) {
Map<String, Object> cluster = this._clusterData.get(i);
Point pointCluster = new Point((Double) cluster.get("x"),
(Double) cluster.get("y"),_mapView.getSpatialReference());
Graphic graphic = new Graphic(pointCluster, cluster, createClusterSymbol(cluster));
this._clusterGraphicsOverlay.getGraphics().add(graphic);
}
}
private Symbol createClusterSymbol(Map<String, Object> cluster) {
int count = (Integer) cluster.get("count");
if (count == 1) {
return markerSymbol;
} else if (count > 1) {
List<Symbol> symbols = new ArrayList<>();
if (count <= 10) {
symbols.add(markerSymbolS);
} else if (count > 10 && count <= 20) {
symbols.add(markerSymbolM);
} else if (count > 20) {
symbols.add(markerSymbolL);
}
TextSymbol textSymbol = new TextSymbol(18, count + "", Color.WHITE,
TextSymbol.HorizontalAlignment.CENTER,
TextSymbol.VerticalAlignment.MIDDLE);
symbols.add(textSymbol);
CompositeSymbol compositeSymbol = new CompositeSymbol(symbols);
return compositeSymbol;
}
return null;
}
SimpleMarkerSymbol markerSymbolL = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE,
Color.RED, 36);
SimpleMarkerSymbol markerSymbolM = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE,
Color.BLUE, 30);
SimpleMarkerSymbol markerSymbolS = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE,
Color.GREEN, 24);
SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE,
Color.YELLOW, 18);
private Envelope _getExtent(Polygon polygon) {
return polygon.getExtent();
}
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment