diff --git a/app/build.gradle b/app/build.gradle index 3f963fba..8d24081c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,8 +24,8 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index d55acb3d..13a16152 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,31 @@ - + xmlns:tools="http://schemas.android.com/tools" + package="com.navinfo.omqs"> + + + + + + + + + + + + + + + + + + + + + + + + @@ -22,6 +47,16 @@ + + \ No newline at end of file diff --git a/app/src/main/assets/MergeOMDB.py b/app/src/main/assets/MergeOMDB.py new file mode 100644 index 00000000..401524b1 --- /dev/null +++ b/app/src/main/assets/MergeOMDB.py @@ -0,0 +1,95 @@ +# coding:utf-8 +# 合并指定目录下的omdb(sqlite)数据 + +import os +import sys +import json +import sqlite3 + + +# 定义遍历目录的函数 +def traverse_dir(path): + fileList = list() + for root, dirs, files in os.walk(path): + for file in files: + if str(file).endswith(".omdb"): + # 文件的完整路径 + file_path = os.path.join(root, file) + # 处理文件,例如读取文件内容等 + print(file_path) + fileList.append(file_path) + return fileList + + +# 打开配置文件,读取用户配置的 +def openConfigJson(path): + # 读取json配置,获取要抽取的表名 + with open(path, "r") as f: + configMap = json.load(f) + return configMap + + +# 按照tableList中指定的表名合并多个源数据库到指定目标数据库中 +def mergeSqliteData(originSqliteList, destSqlite, tableList): + destConn = sqlite3.connect(destSqlite) + destCursor = destConn.cursor() + + for originSqlite in originSqliteList: + originConn = sqlite3.connect(originSqlite) + originCursor = originConn.cursor() + # 从源数据库中遍历取出表list中的数据 + for table in tableList: + # 检查目标数据库中是否存在指定的表 + containsTable = destCursor.execute( + "SELECT sql FROM sqlite_master WHERE type='table' AND name='%s'" % (table)).fetchall() + if not containsTable or len(containsTable) <= 0: + # 复制表结构 + originCursor.execute("SELECT sql FROM sqlite_master WHERE type='table' AND name='%s'" % (table)) + createTableSql = originCursor.fetchone()[0] + destCursor.execute(createTableSql) + destConn.commit() + + originCursor.execute("Select * From " + table) + # 获取到源数据库中该表的所有数据 + originData = originCursor.fetchall() + # 获取一行数据中包含多少列,以此动态设置sql语句中的?个数 + if originData and len(originData)>0: + num_cols = len(originData[0]) + placeholders = ",".join(["?"] * num_cols) + for row in originData: + destCursor.execute("INSERT INTO "+table+" VALUES ({})".format(placeholders), row) + + print("{}数据已导入!".format(originSqlite)) + originCursor.close() + originConn.close() + destConn.commit() + destCursor.close() + destConn.close() + + +if __name__ == '__main__': + params = sys.argv[1:] # 截取参数 + if params: + if not params[0]: + print("请输入要合并的omdb数据的文件夹") + raise AttributeError("请输入要合并的omdb数据的文件夹") + # 获取导出文件的表配置 + jsonPath = params[0] + "/config.json" + if not os.path.exists(jsonPath): + raise AttributeError("指定目录下缺少config.json配置文件") + omdbDir = params[0] + originSqliteList = traverse_dir(omdbDir) # 获取到所有的omdb数据库的路径 + + tableNameList = list() + configMap = openConfigJson(jsonPath) + if configMap["tables"] and len(configMap["tables"]) > 0: + for tableName in set(configMap["tables"]): + tableNameList.append(tableName) + print(tableNameList) + else: + raise AttributeError("config.json文件中没有配置抽取数据的表名") + + # 开始分别连接Sqlite数据库,按照指定表名合并数据 + mergeSqliteData(originSqliteList, params[0]+"/output.sqlite", tableNameList) + else: + raise AttributeError("缺少参数:请输入要合并的omdb数据的文件夹") diff --git a/app/src/main/java/com/navinfo/omqs/QAApplication.kt b/app/src/main/java/com/navinfo/omqs/QAApplication.kt new file mode 100644 index 00000000..faef9dba --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/QAApplication.kt @@ -0,0 +1,10 @@ +package com.navinfo.omqs + +import android.app.Application + +class QAApplication: Application() { + override fun onCreate() { + super.onCreate() + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/model/LoginUser.kt b/app/src/main/java/com/navinfo/omqs/model/LoginUser.kt new file mode 100644 index 00000000..77c0aceb --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/model/LoginUser.kt @@ -0,0 +1,6 @@ +package com.navinfo.omqs.model + +data class LoginUser( + var username: String = "", + var password: String = "" +) \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/LoginActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/LoginActivity.kt deleted file mode 100644 index 6b18b820..00000000 --- a/app/src/main/java/com/navinfo/omqs/ui/LoginActivity.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.navinfo.omqs.ui - -import android.os.Bundle -import android.os.PersistableBundle -import androidx.activity.viewModels -import com.navinfo.omqs.databinding.ActivityLoginBinding - -class LoginActivity : PermissionsActivity() { - - private lateinit var binding: ActivityLoginBinding - private val viewModel by viewModels() - - override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) { - super.onCreate(savedInstanceState, persistentState) - binding = ActivityLoginBinding.inflate(layoutInflater) - setContentView(binding.root) - } - - override fun onPermissionsGranted() { - initView() - } - - private fun initView() { - - } - - override fun onPermissionsDenied() { - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/LoginActivityViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/LoginActivityViewModel.kt deleted file mode 100644 index 10656373..00000000 --- a/app/src/main/java/com/navinfo/omqs/ui/LoginActivityViewModel.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.navinfo.omqs.ui - -import androidx.lifecycle.ViewModel - -class LoginActivityViewModel : ViewModel() { - -} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/MainActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/MainActivity.kt index 281fb87b..0dc22c98 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/MainActivity.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/MainActivity.kt @@ -1,11 +1,7 @@ package com.navinfo.omqs.ui import android.content.Intent -import android.net.Uri import android.os.Bundle -import android.os.FileUtils -import com.google.android.material.snackbar.Snackbar -import androidx.appcompat.app.AppCompatActivity import androidx.core.view.WindowCompat import androidx.navigation.findNavController import androidx.navigation.ui.AppBarConfiguration @@ -13,20 +9,11 @@ import androidx.navigation.ui.navigateUp import androidx.navigation.ui.setupActionBarWithNavController import android.view.Menu import android.view.MenuItem -import android.widget.Toast -import androidx.core.net.toFile -import androidx.lifecycle.LifecycleOwner -import com.blankj.utilcode.util.UriUtils import com.github.k1rakishou.fsaf.FileChooser -import com.github.k1rakishou.fsaf.FileManager import com.github.k1rakishou.fsaf.callback.FSAFActivityCallbacks -import com.github.k1rakishou.fsaf.callback.FileChooserCallback -import com.hjq.permissions.OnPermissionCallback -import com.hjq.permissions.Permission -import com.hjq.permissions.XXPermissions import com.navinfo.omqs.R import com.navinfo.omqs.databinding.ActivityMainBinding -import java.io.File +import com.navinfo.omqs.ui.activity.PermissionsActivity class MainActivity : PermissionsActivity(), FSAFActivityCallbacks { @@ -41,29 +28,27 @@ class MainActivity : PermissionsActivity(), FSAFActivityCallbacks { binding = ActivityMainBinding.inflate(layoutInflater) setContentView(binding.root) - setSupportActionBar(binding.toolbar) - val navController = findNavController(R.id.nav_host_fragment_content_main) appBarConfiguration = AppBarConfiguration(navController.graph) setupActionBarWithNavController(navController, appBarConfiguration) fileChooser.setCallbacks(this@MainActivity) - binding.fab.setOnClickListener { view -> - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAnchorView(R.id.fab) - .setAction("Action", null).show() - // 开始数据导入功能 - fileChooser.openChooseFileDialog(object: FileChooserCallback() { - override fun onCancel(reason: String) { - } - - override fun onResult(uri: Uri) { - val file = UriUtils.uri2File(uri) - Snackbar.make(view, "文件大小为:${file.length()}", Snackbar.LENGTH_LONG) - .show() - } - }) - } +// binding.fab.setOnClickListener { view -> +// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) +// .setAnchorView(R.id.fab) +// .setAction("Action", null).show() +// // 开始数据导入功能 +// fileChooser.openChooseFileDialog(object: FileChooserCallback() { +// override fun onCancel(reason: String) { +// } +// +// override fun onResult(uri: Uri) { +// val file = UriUtils.uri2File(uri) +// Snackbar.make(view, "文件大小为:${file.length()}", Snackbar.LENGTH_LONG) +// .show() +// } +// }) +// } } override fun onPermissionsGranted() { diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/BaseActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/BaseActivity.kt new file mode 100644 index 00000000..481a05f4 --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/BaseActivity.kt @@ -0,0 +1,16 @@ +package com.navinfo.omqs.ui.activity + +import android.content.pm.ActivityInfo +import android.os.Bundle +import android.os.PersistableBundle +import androidx.appcompat.app.AppCompatActivity + +/** + * 基类 + */ +open class BaseActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE//横屏 + super.onCreate(savedInstanceState) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/LoginActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/LoginActivity.kt new file mode 100644 index 00000000..4ba3dd65 --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/LoginActivity.kt @@ -0,0 +1,40 @@ +package com.navinfo.omqs.ui.activity + +import android.content.Intent +import android.os.Bundle +import androidx.activity.viewModels +import androidx.databinding.DataBindingUtil +import com.navinfo.omqs.R +import com.navinfo.omqs.databinding.ActivityLoginBinding + +/** + * 登陆页面 + */ +class LoginActivity : PermissionsActivity() { + + private lateinit var binding: ActivityLoginBinding + private val viewModel by viewModels() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = DataBindingUtil.setContentView(this, R.layout.activity_login) + binding.loginUserModel = viewModel + binding.lifecycleOwner = this + binding.activity = this + } + + override fun onPermissionsGranted() { + } + + override fun onPermissionsDenied() { + } + + /** + * 处理登录按钮 + */ + fun onClickLoginButton() { + val intent = Intent(this@LoginActivity, MainActivity::class.java) + startActivity(intent) + finish() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/LoginViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/LoginViewModel.kt new file mode 100644 index 00000000..29efc8fc --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/LoginViewModel.kt @@ -0,0 +1,23 @@ +package com.navinfo.omqs.ui.activity + +import android.view.View +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import com.navinfo.omqs.model.LoginUser + +class LoginViewModel : ViewModel() { + val loginUser: MutableLiveData = MutableLiveData() + + init { + loginUser.value = LoginUser(username = "admin", password = "123456") + } + + /** + * 处理注册按钮 + */ + fun onClick(view: View) { + loginUser.value!!.username = "admin2" + loginUser.postValue(loginUser.value) + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/MainActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/MainActivity.kt new file mode 100644 index 00000000..94061fbc --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/MainActivity.kt @@ -0,0 +1,45 @@ +package com.navinfo.omqs.ui.activity + +import android.os.Bundle +import androidx.activity.viewModels +import androidx.core.view.WindowCompat +import androidx.databinding.DataBindingUtil +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleEventObserver +import androidx.lifecycle.LifecycleObserver +import androidx.lifecycle.LifecycleOwner +import com.navinfo.omqs.R +import com.navinfo.omqs.databinding.ActivityMainBinding + +/** + * 地图主页面 + */ +class MainActivity : BaseActivity() { + + private lateinit var binding: ActivityMainBinding + private val viewModel by viewModels() + override fun onCreate(savedInstanceState: Bundle?) { + WindowCompat.setDecorFitsSystemWindows(window, false) + super.onCreate(savedInstanceState) + + binding = DataBindingUtil.setContentView(this, R.layout.activity_main) + //关联生命周期 + binding.lifecycleOwner = this + //给xml转递对象 + binding.mainActivity = this + //给xml传递viewModel对象 + binding.viewModel = viewModel + //初始化地图 + viewModel.initMap(this, binding.mapView.mainActivityMap) + //让viewModel监听activity生命周期 + lifecycle.addObserver(viewModel) + } + + /** + * 打开个人中菜单 + */ + fun openMenu() { + binding.mainActivityDrawer.open() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/MainViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/MainViewModel.kt new file mode 100644 index 00000000..242c9673 --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/MainViewModel.kt @@ -0,0 +1,53 @@ +package com.navinfo.omqs.ui.activity + +import android.app.Application +import android.content.Context +import androidx.lifecycle.AndroidViewModel +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.ViewModel +import com.navinfo.collect.library.map.NIMapController +import com.navinfo.collect.library.map.NIMapView + +class MainViewModel(val app: Application) : AndroidViewModel(app), DefaultLifecycleObserver { + /** + * 地图控制器 + */ + private lateinit var mapController: NIMapController + + /** + * 初始化地图 + */ + fun initMap(context: Context, mapView: NIMapView) { + mapController = NIMapController(context = app, mapView = mapView) + + } + + override fun onStart(owner: LifecycleOwner) { + super.onStart(owner) + //开启定位 + mapController.locationLayerHandler.startLocation() + } + + override fun onPause(owner: LifecycleOwner) { + mapController.mMapView.onPause() + } + + override fun onDestroy(owner: LifecycleOwner) { + mapController.mMapView.onDestroy() + //结束定位 + mapController.locationLayerHandler.stopLocation() + } + + override fun onResume(owner: LifecycleOwner) { + mapController.mMapView.onResume() + } + + /** + * 点击我的位置,回到我的位置 + */ + fun onClickLocationButton() { + mapController.locationLayerHandler.animateToCurrentPosition() + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/MapTestActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/MapTestActivity.kt new file mode 100644 index 00000000..44918797 --- /dev/null +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/MapTestActivity.kt @@ -0,0 +1,16 @@ +package com.navinfo.omqs.ui.activity + +import android.os.Bundle +import com.navinfo.collect.library.map.NIMapController +import com.navinfo.collect.library.map.NIMapView +import com.navinfo.omqs.R + +class MapTestActivity: BaseActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_map_test) + + val mapController = NIMapController(context = this, mapView = findViewById(R.id.main_activity_map1)) + mapController.locationLayerHandler.startLocation() + } +} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/PermissionsActivity.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/PermissionsActivity.kt similarity index 58% rename from app/src/main/java/com/navinfo/omqs/ui/PermissionsActivity.kt rename to app/src/main/java/com/navinfo/omqs/ui/activity/PermissionsActivity.kt index a175c633..fa584a95 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/PermissionsActivity.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/PermissionsActivity.kt @@ -1,9 +1,8 @@ -package com.navinfo.omqs.ui +package com.navinfo.omqs.ui.activity +import android.os.Build import android.os.Bundle -import android.os.PersistableBundle import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity import com.hjq.permissions.OnPermissionCallback import com.hjq.permissions.Permission import com.hjq.permissions.XXPermissions @@ -11,18 +10,31 @@ import com.hjq.permissions.XXPermissions /** * 权限申请Activity */ -abstract class PermissionsActivity : AppCompatActivity() { +open class PermissionsActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - + val permissionList = mutableListOf() + if (applicationInfo.targetSdkVersion >= Build.VERSION_CODES.TIRAMISU) { + //文件读写 +// permissionList.add(Permission.READ_MEDIA_IMAGES) +// permissionList.add(Permission.READ_MEDIA_AUDIO) +// permissionList.add(Permission.READ_MEDIA_VIDEO) + permissionList.add(Permission.MANAGE_EXTERNAL_STORAGE) + } else { + //文件读写 + permissionList.add(Permission.WRITE_EXTERNAL_STORAGE) + permissionList.add(Permission.READ_EXTERNAL_STORAGE) + permissionList.add(Permission.READ_MEDIA_VIDEO) + } + //定位权限 + permissionList.add(Permission.ACCESS_FINE_LOCATION) + permissionList.add(Permission.ACCESS_COARSE_LOCATION) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + permissionList.add(Permission.ACCESS_BACKGROUND_LOCATION) + } XXPermissions.with(this) // 申请单个权限 -// .permission(Permission.WRITE_EXTERNAL_STORAGE) -// .permission(Permission.READ_EXTERNAL_STORAGE) -// .permission(Permission.READ_MEDIA_IMAGES) -// .permission(Permission.READ_MEDIA_AUDIO) -// .permission(Permission.READ_MEDIA_VIDEO) - .permission(Permission.MANAGE_EXTERNAL_STORAGE) + .permission(permissionList) // 设置权限请求拦截器(局部设置) //.interceptor(new PermissionInterceptor()) // 设置不触发错误检测机制(局部设置) @@ -39,6 +51,8 @@ abstract class PermissionsActivity : AppCompatActivity() { .show() onPermissionsGranted() return + } else { + onPermissionsDenied() } // 在SD卡创建项目目录 } @@ -55,11 +69,23 @@ abstract class PermissionsActivity : AppCompatActivity() { XXPermissions.startPermissionActivity(this@PermissionsActivity, permissions) onPermissionsDenied() } else { + onPermissionsDenied() } } }) } - abstract fun onPermissionsGranted() - abstract fun onPermissionsDenied() + /** + * 权限全部同意 + */ + open fun onPermissionsGranted() { + + } + + /** + * 权限 + */ + open fun onPermissionsDenied() { + + } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/FirstFragment.kt b/app/src/main/java/com/navinfo/omqs/ui/fragment/FirstFragment.kt similarity index 95% rename from app/src/main/java/com/navinfo/omqs/FirstFragment.kt rename to app/src/main/java/com/navinfo/omqs/ui/fragment/FirstFragment.kt index 038ba3e0..ab8943a7 100644 --- a/app/src/main/java/com/navinfo/omqs/FirstFragment.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/fragment/FirstFragment.kt @@ -1,4 +1,4 @@ -package com.navinfo.omqs +package com.navinfo.omqs.ui.fragment import android.os.Bundle import androidx.fragment.app.Fragment @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.navigation.fragment.findNavController +import com.navinfo.omqs.R import com.navinfo.omqs.databinding.FragmentFirstBinding /** diff --git a/app/src/main/java/com/navinfo/omqs/SecondFragment.kt b/app/src/main/java/com/navinfo/omqs/ui/fragment/SecondFragment.kt similarity index 93% rename from app/src/main/java/com/navinfo/omqs/SecondFragment.kt rename to app/src/main/java/com/navinfo/omqs/ui/fragment/SecondFragment.kt index 7e3e1b25..b9a3bffb 100644 --- a/app/src/main/java/com/navinfo/omqs/SecondFragment.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/fragment/SecondFragment.kt @@ -1,4 +1,4 @@ -package com.navinfo.omqs +package com.navinfo.omqs.ui.fragment import android.os.Bundle import androidx.fragment.app.Fragment @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.navigation.fragment.findNavController +import com.navinfo.omqs.R import com.navinfo.omqs.databinding.FragmentSecondBinding /** @@ -22,7 +23,7 @@ class SecondFragment : Fragment() { override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? - ): View? { + ): View { _binding = FragmentSecondBinding.inflate(inflater, container, false) return binding.root diff --git a/app/src/main/res/drawable/baseline_my_location_24.xml b/app/src/main/res/drawable/baseline_my_location_24.xml new file mode 100644 index 00000000..5747dc82 --- /dev/null +++ b/app/src/main/res/drawable/baseline_my_location_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/baseline_person_24.xml b/app/src/main/res/drawable/baseline_person_24.xml new file mode 100644 index 00000000..f96a32ae --- /dev/null +++ b/app/src/main/res/drawable/baseline_person_24.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index a074df1d..f42901d3 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,9 +1,101 @@ - + tools:context=".ui.activity.LoginActivity"> - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 928ac25a..73ea5e7b 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,34 +1,41 @@ - + tools:context=".ui.activity.MainActivity"> - + + + + + + + - + android:layout_height="match_parent" + app:mainActivity="@{mainActivity}" + app:viewModel="@{viewModel}"/> - - - - - - - \ No newline at end of file + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_map_test.xml b/app/src/main/res/layout/activity_map_test.xml new file mode 100644 index 00000000..0d477f41 --- /dev/null +++ b/app/src/main/res/layout/activity_map_test.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_first.xml b/app/src/main/res/layout/fragment_first.xml index ddd95756..d7283fad 100644 --- a/app/src/main/res/layout/fragment_first.xml +++ b/app/src/main/res/layout/fragment_first.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context=".FirstFragment"> + tools:context=".ui.fragment.FirstFragment"> + tools:context=".ui.fragment.SecondFragment"> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/nav_header_main.xml b/app/src/main/res/layout/nav_header_main.xml new file mode 100644 index 00000000..30935119 --- /dev/null +++ b/app/src/main/res/layout/nav_header_main.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/activity_main_drawer.xml b/app/src/main/res/menu/activity_main_drawer.xml new file mode 100644 index 00000000..b80a9585 --- /dev/null +++ b/app/src/main/res/menu/activity_main_drawer.xml @@ -0,0 +1,20 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 9693f9e4..5c0fb2ec 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -1,7 +1,7 @@ + tools:context="com.navinfo.omqs.ui.activity.MainActivity"> @@ -17,7 +17,7 @@ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 125df871..0124e0d2 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,3 +1,8 @@ 16dp + + 16dp + 16dp + 8dp + 176dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4f4827da..7987a657 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -43,4 +43,18 @@ libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim. + 请输入用户名 + 请输入密码 + 登录 + 注册 + imageDescription + Open navigation drawer + Close navigation drawer + Android Studio + android.studio@android.com + Navigation header + + Home + Gallery + Slideshow \ No newline at end of file diff --git a/collect-library/build.gradle b/collect-library/build.gradle index 7ea37c25..9cc1452d 100644 --- a/collect-library/build.gradle +++ b/collect-library/build.gradle @@ -56,7 +56,7 @@ android { dependencies { api fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - + api files('libs/BaiduLBS_AndroidSDK_Lib.aar') implementation "androidx.appcompat:appcompat:$appcompatVersion" implementation "com.google.android.material:material:$materialVersion" testImplementation 'junit:junit:4.13.2' @@ -106,11 +106,10 @@ dependencies { implementation "androidx.sqlite:sqlite:2.0.1" implementation "androidx.room:room-runtime:2.1.0" annotationProcessor "androidx.room:room-compiler:2.1.0" - kapt 'android.arch.persistence.room:compiler:1.1.1' // compiler 需要用 room 的 kapt "androidx.room:room-compiler:2.1.0" - androidTestImplementation "android.arch.persistence.room:testing:1.1.1" - implementation "android.arch.lifecycle:extensions:1.1.1" - kapt "android.arch.lifecycle:compiler:1.1.1" + androidTestImplementation 'androidx.room:room-testing:2.0.0' + implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' + kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0' implementation 'com.tencent.wcdb:wcdb-android:1.0.0' implementation "androidx.core:core-ktx:1.8.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" diff --git a/collect-library/libs/BaiduLBS_AndroidSDK_Lib.aar b/collect-library/libs/BaiduLBS_AndroidSDK_Lib.aar new file mode 100644 index 00000000..18d4fe80 Binary files /dev/null and b/collect-library/libs/BaiduLBS_AndroidSDK_Lib.aar differ diff --git a/collect-library/src/main/AndroidManifest.xml b/collect-library/src/main/AndroidManifest.xml index 4aeba678..5f8fe9fa 100644 --- a/collect-library/src/main/AndroidManifest.xml +++ b/collect-library/src/main/AndroidManifest.xml @@ -8,13 +8,14 @@ - - - - - - - - + + + + \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/BaseActivity.java b/collect-library/src/main/java/com/navinfo/collect/BaseActivity.java index fcbb0385..3a992a65 100644 --- a/collect-library/src/main/java/com/navinfo/collect/BaseActivity.java +++ b/collect-library/src/main/java/com/navinfo/collect/BaseActivity.java @@ -1,111 +1,117 @@ -package com.navinfo.collect; - -import android.Manifest; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.provider.Settings; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.PermissionChecker; - -/** - * Created by linyiran on 6/16/22. - */ -public abstract class BaseActivity extends AppCompatActivity { - private static final int REQUEST_PERMISSION = 1; - - protected boolean allPermissionsGranted; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setLayout(); - requestPermission(); - onActivityCreated(savedInstanceState); - } - - protected abstract void setLayout(); - - protected abstract void onActivityCreated(Bundle savedInstanceState); - - private void requestPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - String[] permissions = new String[]{ - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.INTERNET, - Manifest.permission.ACCESS_NETWORK_STATE, - Manifest.permission.READ_PHONE_STATE, - Manifest.permission.CAMERA - }; - allPermissionsGranted = true; - for (String perm : permissions) { - if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) { - allPermissionsGranted = false; - break; - } - } - if (!allPermissionsGranted) { - ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION); - } else { - requestAllFilesAccess(); - } - } else { - allPermissionsGranted = true; - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, - @NonNull int[] grantResults) { - if (requestCode == REQUEST_PERMISSION) { - allPermissionsGranted = true; - for (int grantRes : grantResults) { - if (grantRes != PackageManager.PERMISSION_GRANTED) { - allPermissionsGranted = false; - break; - } - } - if (allPermissionsGranted) { - requestAllFilesAccess(); - } - } - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - } - - /** - * Android 11 跳转到设置获取SD卡根目录写入权限 - */ - private void requestAllFilesAccess() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) { - allPermissionsGranted = false; - - AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this, - androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert); - alertBuilder.setMessage("需授权访问SD卡文件"); - alertBuilder.setCancelable(false); - alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - } - }); - alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - alertBuilder.show(); - } - } -} +//package com.navinfo.collect; +// +//import android.Manifest; +//import android.content.DialogInterface; +//import android.content.Intent; +//import android.content.pm.PackageManager; +//import android.os.Build; +//import android.os.Bundle; +//import android.os.Environment; +//import android.provider.Settings; +// +//import androidx.annotation.NonNull; +//import androidx.annotation.Nullable; +//import androidx.appcompat.app.AlertDialog; +//import androidx.appcompat.app.AppCompatActivity; +//import androidx.core.app.ActivityCompat; +//import androidx.core.content.PermissionChecker; +// +//import com.baidu.ai.edge.core.base.Consts; +// +// +///** +// * Created by linyiran on 6/16/22. +// */ +//public abstract class BaseActivity extends AppCompatActivity { +// private static final int REQUEST_PERMISSION = 1; +// +// protected boolean allPermissionsGranted; +// +// @Override +// protected void onCreate(@Nullable Bundle savedInstanceState) { +// super.onCreate(savedInstanceState); +// setLayout(); +// requestPermission(); +// onActivityCreated(savedInstanceState); +// } +// +// protected abstract void setLayout(); +// +// protected abstract void onActivityCreated(Bundle savedInstanceState); +// +// private void requestPermission() { +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { +// String[] permissions = new String[]{ +// Manifest.permission.WRITE_EXTERNAL_STORAGE, +// Manifest.permission.INTERNET, +// Manifest.permission.ACCESS_NETWORK_STATE, +// Manifest.permission.READ_PHONE_STATE, +// Manifest.permission.CAMERA +// }; +// allPermissionsGranted = true; +// for (String perm : permissions) { +// if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) { +// allPermissionsGranted = false; +// break; +// } +// } +// if (!allPermissionsGranted) { +// ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION); +// } else { +// requestAllFilesAccess(); +// } +// } else { +// allPermissionsGranted = true; +// } +// } +// +// @Override +// public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, +// @NonNull int[] grantResults) { +// if (requestCode == REQUEST_PERMISSION) { +// allPermissionsGranted = true; +// for (int grantRes : grantResults) { +// if (grantRes != PackageManager.PERMISSION_GRANTED) { +// allPermissionsGranted = false; +// break; +// } +// } +// if (allPermissionsGranted) { +// requestAllFilesAccess(); +// } +// } +// super.onRequestPermissionsResult(requestCode, permissions, grantResults); +// } +// +// /** +// * Android 11 跳转到设置获取SD卡根目录写入权限 +// */ +// private void requestAllFilesAccess() { +// if (!Consts.AUTH_REQUIRE_SDCARD) { +// return; +// } +// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) { +// allPermissionsGranted = false; +// +// AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this, +// androidx.appcompat.R.style.Theme_AppCompat_Light_Dialog_Alert); +// alertBuilder.setMessage("需授权访问SD卡文件"); +// alertBuilder.setCancelable(false); +// alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() { +// @Override +// public void onClick(DialogInterface dialog, int which) { +// Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); +// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); +// startActivity(intent); +// } +// }); +// alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() { +// @Override +// public void onClick(DialogInterface dialog, int which) { +// dialog.dismiss(); +// } +// }); +// alertBuilder.show(); +// } +// } +//} diff --git a/collect-library/src/main/java/com/navinfo/collect/FlutterBaseActivity.kt b/collect-library/src/main/java/com/navinfo/collect/FlutterBaseActivity.kt new file mode 100644 index 00000000..865be3f1 --- /dev/null +++ b/collect-library/src/main/java/com/navinfo/collect/FlutterBaseActivity.kt @@ -0,0 +1,43 @@ +//package com.navinfo.collect +// +//import android.content.Intent +//import android.util.Log +//import com.baidu.ai.edge.ui.view.model.BasePolygonResultModel +//import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFactory +//import com.navinfo.collect.library.map.flutter.plugin.FlutterMapViewFlutterPlugin +//import io.flutter.embedding.android.FlutterActivity +//import io.flutter.embedding.engine.FlutterEngine +//import kotlinx.coroutines.CoroutineScope +//import kotlinx.coroutines.MainScope +//import kotlinx.coroutines.cancel +// +//abstract class FlutterBaseActivity : FlutterActivity(), CoroutineScope by MainScope() { +// lateinit var factory: FlutterMapViewFactory +// override fun configureFlutterEngine(flutterEngine: FlutterEngine) { +// super.configureFlutterEngine(flutterEngine) +// factory = FlutterMapViewFlutterPlugin.registerWith(flutterEngine, this); +//// FlutterNiMapCopyViewFlutterPlugin.registerWith(flutterEngine, this); +// } +// +// override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { +// super.onActivityResult(requestCode, resultCode, data) +// if (resultCode == 0x10 && data != null) { +// val path = data.getStringExtra("photo_path") +// val list = data.getParcelableArrayListExtra("result_list") +// Log.e("jingo","OCR java 返回的数据:"+ path + list.toString()); +// if (path != null && list != null) { +// factory.dataController.flutterDataCameraHandler.sendOcrResults( +// path, +// list as List +// ) +// } +// } +// } +// +// override fun onDestroy() { +// super.onDestroy() +// //协程销毁 +// cancel() +// } +// +//} \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/data/RealmUtils.java b/collect-library/src/main/java/com/navinfo/collect/library/data/RealmUtils.java index 6f82be74..c5da1a20 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/data/RealmUtils.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/data/RealmUtils.java @@ -6,7 +6,6 @@ import android.util.Log; import com.google.protobuf.GeneratedMessageV3; import com.navinfo.collect.library.data.entity.GeometryFeatureEntity; import com.navinfo.collect.library.data.entity.LayerEntity; -import com.navinfo.collect.library.map.NILayerManager; import com.navinfo.collect.library.utils.GeometryTools; import com.navinfo.onemap.det.sdkpbf.proto.crowdsource.Hadlanelink; import com.navinfo.onemap.det.sdkpbf.proto.crowdsource.Hadlanemarklink; @@ -48,7 +47,7 @@ public class RealmUtils { private static RealmUtils instance; private Realm realm; private RealmConfiguration realmConfiguration; - private String defaultDir = NILayerManager.defaultDir; + private String defaultDir = "";//NILayerManager.defaultDir; private String realmName; private final String NAME = "name"; diff --git a/collect-library/src/main/java/com/navinfo/collect/library/data/handler/DataCameraHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/data/handler/DataCameraHandler.kt new file mode 100644 index 00000000..9c3e323d --- /dev/null +++ b/collect-library/src/main/java/com/navinfo/collect/library/data/handler/DataCameraHandler.kt @@ -0,0 +1,223 @@ +//package com.navinfo.collect.library.data.handler +// +//import android.content.Context +//import android.graphics.Bitmap +//import android.graphics.BitmapFactory +//import android.media.ExifInterface +//import android.util.Log +//import com.baidu.ai.edge.ui.util.ImageUtil +//import com.baidu.ai.edge.ui.view.model.OcrViewResultModel +//import com.navinfo.collect.FlutterBaseActivity +//import com.navinfo.collect.library.data.dao.impl.MapLifeDataBase +//import com.navinfo.ocr.OCRManager +//import kotlinx.coroutines.Dispatchers +//import kotlinx.coroutines.launch +//import kotlinx.coroutines.withContext +//import java.io.* +//import java.util.* +// +//interface OnOCRBatchListener { +// fun onProgress(total: Int, current: Int) +// suspend fun onResult(list: List>) +//} +// +//open class DataCameraHandler( +// context: Context, +// activity: FlutterBaseActivity, +// dataBase: MapLifeDataBase +//) : +// BaseDataHandler(context, dataBase) { +// +// private val mActivity: FlutterBaseActivity = activity +// +// init { +// OCRManager.instance.init(activity) +// } +// +// fun openCamera() { +// OCRManager.instance.openCamera(mActivity) +// } +// +// /** +// * 批量OCR识别 +// */ +// fun ocrBatch(filePath: String, listener: OnOCRBatchListener) { +// mActivity.launch(Dispatchers.IO) { +// Log.e("jingo", "OCRManager 线程开始 ${Thread.currentThread().name}") +// val file = File(filePath) +// val resultList = mutableListOf>() +// if (file.isDirectory) { +// val fileList = file.listFiles() +// val bitmapList = mutableListOf() +// for (item in fileList!!) { +// if (item.isFile) { +// if (checkIsImageFile(item.name)) { +// bitmapList.add(item.path) +// } +// } +// } +// val bfw: BufferedWriter +// val csvFile = File("$filePath/ocr.csv") +// val out: FileOutputStream +// val osw: OutputStreamWriter +// try { +// out = FileOutputStream(csvFile) +// //用excel打开,中文会乱码,所以用GBK编译 +// osw = OutputStreamWriter(out, "GBK") +// bfw = BufferedWriter(osw) +// //第一行表头数据 +// bfw.write("图片路径和名称,") +// bfw.write("识别结果序号,") +// bfw.write("识别结果内容,") +// bfw.write("置信度,") +// bfw.write("识别面积,") +// bfw.write("图片大小,") +// bfw.write("识别区域,") +// //写好表头后换行 +// bfw.newLine() +// for (i in 0 until bitmapList.size) { +// val path = bitmapList[i] +// +// val bitmap: Bitmap? = readFile(path) +// var exif = ExifInterface(path) +// val exifRotation = exif.getAttributeInt( +// ExifInterface.TAG_ORIENTATION, +// ExifInterface.ORIENTATION_NORMAL +// ) +// val rotation = ImageUtil.exifToDegrees(exifRotation) +// val rotateBitmap = ImageUtil.createRotateBitmap(bitmap, rotation) +// val list = OCRManager.instance.ocr(rotateBitmap) +// +// +//// val list = ocrBitmap(path) +// if (list != null) { +// for (o in list) { +// bfw.write("$path,") +// bfw.write("${o.index},") +// bfw.write("${o.name},") +// bfw.write("${o.confidence.toString()},") +// val pointList = o.bounds +// bfw.write("${(pointList[3].y - pointList[0].y) * (pointList[2].x - pointList[0].x)},") +// bfw.write("${rotateBitmap.width} ${rotateBitmap.height},") +// bfw.write("${o.bounds[0].x} ${o.bounds[0].y};${o.bounds[1].x} ${o.bounds[1].y};${o.bounds[2].x} ${o.bounds[2].y};${o.bounds[3].x} ${o.bounds[3].y},") +// bfw.newLine() +// } +// bfw.newLine() +// withContext(Dispatchers.Main) { +// listener.onProgress(bitmapList.size, i) +// } +// val m1 = mutableMapOf(); +// m1["data"] = list; +// m1["width"] = rotateBitmap.width +// m1["height"] = rotateBitmap.height +// m1["path"] = path +// resultList.add(m1) +// } +// rotateBitmap.recycle() +// } +// +// //将缓存数据写入文件 +// bfw.flush() +// //释放缓存 +// bfw.close() +// osw.close() +// out.close() +// } catch (e: Throwable) { +// +// } +// //将缓存数据写入文件 +// +// withContext(Dispatchers.Main) { +// Log.e("jingo", "OCRManager 线程名称2 ${Thread.currentThread().name}") +// listener.onResult(resultList) +// } +// } else if (file.isFile && checkIsImageFile(file.name)) { +// val list = ocrBitmap(filePath) +// if (list != null) { +// withContext(Dispatchers.Main) { +// Log.e("jingo", "OCRManager 线程名称2 ${Thread.currentThread().name}") +// listener.onProgress(1, 1) +// } +// val m = mutableMapOf>() +// m[file.name] = list +// resultList.add(m) +// } +// withContext(Dispatchers.Main) { +// Log.e("jingo", "OCRManager 线程名称2 ${Thread.currentThread().name}") +// listener.onResult(resultList) +// } +// } +// +// } +// } +// +// private fun ocrBitmap(path: String): List? { +// try { +// val bitmap: Bitmap? = readFile(path) +// var exif = ExifInterface(path) +// val exifRotation = exif.getAttributeInt( +// ExifInterface.TAG_ORIENTATION, +// ExifInterface.ORIENTATION_NORMAL +// ) +// val rotation = ImageUtil.exifToDegrees(exifRotation) +// val rotateBitmap = ImageUtil.createRotateBitmap(bitmap, rotation) +// val res = OCRManager.instance.ocr(rotateBitmap) +// rotateBitmap.recycle() +// return res +// } catch (e: IOException) { +// Log.e("jingo", "图像识别,获取图像信息失败 ${e.printStackTrace()}") +// } +// return null +// } +// +// /** +// * 检查是不是bitmap文件 +// */ +// private fun checkIsImageFile(fName: String): Boolean { +// val isImageFile: Boolean +// // 获取扩展名 +// val fileEnd = fName.substring( +// fName.lastIndexOf(".") + 1, +// fName.length +// ).lowercase(Locale.getDefault()) +// isImageFile = +// fileEnd == "jpg" || fileEnd == "png" || fileEnd == "webp" || fileEnd == "jpeg" || fileEnd == "bmp" +// return isImageFile +// } +// +// /** +// * 读取bitmap文件 +// */ +// private fun readFile(path: String): Bitmap? { +// var stream: FileInputStream? = null +// try { +// stream = FileInputStream(path) +// return BitmapFactory.decodeStream(stream) +// } catch (e: FileNotFoundException) { +// e.printStackTrace() +// } finally { +// if (stream != null) { +// try { +// stream.close() +// } catch (e: IOException) { +// e.printStackTrace() +// } +// } +// } +// return null +// } +// +//// private fun onOcrBitmap( +//// bitmap, confidence, +//// object: OcrListener { +//// override fun onResult(models: List) { +//// if (models == null) { +//// listener.onResult(null) +//// return +//// } +//// ocrResultModelCache = models +//// listener.onResult(models) +//// } +//// }) +// +//} \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/NILayerManager.java b/collect-library/src/main/java/com/navinfo/collect/library/map/NILayerManager.java index 34a3c063..36ab9c24 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/NILayerManager.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/NILayerManager.java @@ -1,331 +1,331 @@ -package com.navinfo.collect.library.map; - -import android.app.Activity; -import android.content.Context; -import android.graphics.BitmapFactory; -import android.graphics.Color; -import android.location.Location; -import android.os.Environment; -import android.text.TextPaint; -import android.util.Log; -import android.widget.TextView; -import android.widget.Toast; - -import com.badlogic.gdx.maps.MapGroupLayer; -import com.navinfo.collect.library.R; -import com.navinfo.collect.library.map.layers.NIPolygonLayer; -import com.navinfo.collect.library.map.source.NavinfoMapRastorTileSource; -import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource; -import com.navinfo.collect.library.utils.DistanceUtil; -import com.navinfo.collect.library.utils.GeometryTools; -import com.navinfo.collect.library.utils.StringUtil; - -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.Polygon; -import org.oscim.android.canvas.AndroidBitmap; -import org.oscim.backend.CanvasAdapter; -import org.oscim.backend.canvas.Bitmap; -import org.oscim.core.GeoPoint; -import org.oscim.core.MapPosition; -import org.oscim.event.Event; -import org.oscim.layers.Layer; -import org.oscim.layers.LocationLayer; -import org.oscim.layers.marker.ItemizedLayer; -import org.oscim.layers.marker.MarkerInterface; -import org.oscim.layers.marker.MarkerItem; -import org.oscim.layers.marker.MarkerSymbol; -import org.oscim.layers.tile.bitmap.BitmapTileLayer; -import org.oscim.layers.tile.vector.VectorTileLayer; -import org.oscim.layers.vector.geometries.Drawable; -import org.oscim.layers.vector.geometries.PointDrawable; -import org.oscim.layers.vector.geometries.PolygonDrawable; -import org.oscim.layers.vector.PathLayer; -import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; -import org.oscim.tiling.source.OkHttpEngine; - -import java.io.File; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import okhttp3.Cache; -import okhttp3.OkHttpClient; - -public class NILayerManager implements ItemizedLayer.OnItemGestureListener { - private Map vtmMap; - public static String defaultDir = Environment.getExternalStorageDirectory() + "/" + "NavinfoCollect"; - private String defaultLocalMapPath = defaultDir + "/maps/"; - //图层管理 - private java.util.Map layersMap = new HashMap(); - //默认marker图层 - private ItemizedLayer mDefaultMarkerLayer; - //定位图层 - private LocationLayer mLocationLayer; - private NIPolygonLayer mPolygonLayer; - private List mPathMakers = new ArrayList<>(); - private Location mCurrentLocation; // 当前位置信息 - - public static final String MARQUEE_MARKER_LAYER = "MarqueeMarker"; - - private Context mCon; - - private java.util.Map vectorLayerMap; // 维护vector图层的map数据,key为图层名称(一般对应为矢量数据的数据源),value为图层 - - public NILayerManager(Context context, Map vtmMap) { - this.vtmMap = vtmMap; - this.mCon = context; - - //新增marker图标样式 - AndroidBitmap mDefaultBitmap = - new AndroidBitmap(BitmapFactory.decodeResource(context.getResources(), R.mipmap.marker)); - MarkerSymbol markerSymbol = new MarkerSymbol(mDefaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); - //新增marker图层 - mDefaultMarkerLayer = new ItemizedLayer( - vtmMap, - new ArrayList(), - markerSymbol, - this - ); - addLayer("defaultMarkerLayer", mDefaultMarkerLayer, NIMapView.LAYER_GROUPS.VECTOR.ordinal()); - - //定位图层 - mLocationLayer = new LocationLayer(vtmMap); - addLayer("locationLayer", mLocationLayer, NIMapView.LAYER_GROUPS.ALLWAYS_SHOW_GROUP.ordinal()); - - if (this.vectorLayerMap == null) { - this.vectorLayerMap = new HashMap<>(); - } - } - - public Layer getRasterTileLayer(Context mContext, String url, String tilePath, boolean useCache) { - if (this.vtmMap == null) { - throw new IllegalStateException("无法获取到map对象"); - } - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - NavinfoMapRastorTileSource mTileSource = NavinfoMapRastorTileSource.builder(url).tilePath(tilePath).httpFactory(new OkHttpEngine.OkHttpFactory(builder)).build(); - // 如果使用缓存 - if (useCache) { - File cacheDirectory = new File(defaultDir, "tiles-raster"); - int cacheSize = 300 * 1024 * 1024; // 300 MB - Cache cache = new Cache(cacheDirectory, cacheSize); - builder.cache(cache); - } - -// mTileSource.setHttpEngine(new OkHttpEngine.OkHttpFactory(builder)); -// mTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example")); -// mTileSource.setCache(new TileCache(mContext, defaultDir, url.substring(url.indexOf(":")+1))); - - BitmapTileLayer rasterLayer = new BitmapTileLayer(this.vtmMap, mTileSource); - return rasterLayer; - } - - // 初始化请求在线底图数据 - public Layer getDefaultVectorLayer(boolean useCache) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - if (useCache) { - // Cache the tiles into file system - File cacheDirectory = new File(defaultDir, "tiles-vector"); - int cacheSize = 200 * 1024 * 1024; // 200 MB - Cache cache = new Cache(cacheDirectory, cacheSize); - builder.cache(cache); - } - - NavinfoMultiMapFileTileSource tileSource = NavinfoMultiMapFileTileSource.builder() - .apiKey("4wTLZyXcQym31pxC_HGy7Q") // Put a proper API key - .httpFactory(new OkHttpEngine.OkHttpFactory(builder)) - //.locale("en") - .build(); - HashMap headerMap = new HashMap<>(); - headerMap.put("token", "eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6MTAzLCJ1c2VyTmFtZSI6ImFkbWluIiwidXNlcklkIjoxLCJ1c2VyR3JvdXAiOiLnoJTlj5Hpg6giLCJvcmdJZCI6MSwiaWF0IjoxNjMwOTk4MzI5LCJleHAiOjE2MzEwODQ3Mjl9.0wFm8mAA9dCC2FmZj-u1dhxTFDRYx8AqVnh2C88hitk"); - tileSource.setHttpRequestHeaders(headerMap); - VectorTileLayer l = new VectorTileLayer(this.vtmMap, tileSource); - return l; - } - - public void addLayer(String tag, Layer layer) { - if (!layersMap.containsKey(tag)) { - layersMap.put(tag, layer); - vtmMap.layers().add(layer); - } - } - - - public void addLayer(String tag, Layer layer, int group) { - if (!layersMap.containsKey(tag)) { - layersMap.put(tag, layer); - vtmMap.layers().add(layer, group); - } - } - - public void addLayer(int index, String tag, Layer layer) { - if (!layersMap.containsKey(tag)) { - layersMap.put(tag, layer); - vtmMap.layers().add(index, layer); - } - } - - public boolean containsLayer(String tag) { - return layersMap.containsKey(tag); - } - - public Layer getLayer(String tag) { - return layersMap.get(tag); - } - - public void removeLayer(String tag) { - if (layersMap.containsKey(tag)) { - Layer layer = layersMap.remove(tag); - vtmMap.layers().remove(layer); - } - } - - /** - * 返回默认marker图层 - * - * @return mDefaultMarkerLayer - */ - public ItemizedLayer getDefaultMarkerLayer() { - return mDefaultMarkerLayer; - } - - /** - * 返回定位图层 - * - * @return mLocationLayer - */ - public LocationLayer getLocationLayer() { - return mLocationLayer; - } - - - @Override - public boolean onItemSingleTapUp(int index, Object item) { - return false; - } - - @Override - public boolean onItemLongPress(int index, Object item) { - return false; - } - - /** - * 定位 - * @param lon - * @param lat - * @param time - */ - public void jumpToPosition(double lon, double lat, long time) { - MapPosition mapPosition = vtmMap.getMapPosition(); - mapPosition.setPosition(lat, lon); - vtmMap.animator().animateTo(time, mapPosition); - } - - /** - * 定位 - * @param lon - * @param lat - * @param zoomLevel - */ - public void jumpToPosition(double lon, double lat, int zoomLevel) { - MapPosition mapPosition = vtmMap.getMapPosition(); - if (mapPosition.getZoomLevel() < zoomLevel) { - mapPosition.setZoomLevel(zoomLevel); - } - mapPosition.setPosition(lat, lon); - vtmMap.animator().animateTo(300, mapPosition); - } - - public void addMarker2MarkerLayer(MarkerInterface markerItem, Bitmap defaultBitmap, String layerName, int layerGroup) { - if (markerItem == null) { - return; - } - if (vectorLayerMap != null) { - if (!vectorLayerMap.containsKey(layerName) || vectorLayerMap.get(layerName) == null) { - MarkerSymbol symbol = new MarkerSymbol(defaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); - vectorLayerMap.put(layerName, new ItemizedLayer(vtmMap, symbol)); - } - - ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); - itemizedLayer.addItem(markerItem); - if (!vtmMap.layers().contains(itemizedLayer)) { - vtmMap.layers().add(itemizedLayer, layerGroup); - } - itemizedLayer.update(); - } - } - - public void addMarker2MarkerLayer(MarkerInterface markerItem, Bitmap defaultBitmap, String layerName, int layerGroup, ItemizedLayer.OnItemGestureListener listener) { - if (markerItem == null) { - return; - } - if (vectorLayerMap != null) { - if (!vectorLayerMap.containsKey(layerName) || vectorLayerMap.get(layerName) == null) { - MarkerSymbol symbol = new MarkerSymbol(defaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); - vectorLayerMap.put(layerName, new ItemizedLayer(vtmMap, new ArrayList(), symbol, listener)); - } - - ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); - itemizedLayer.addItem(markerItem); - if (!vtmMap.layers().contains(itemizedLayer)) { - vtmMap.layers().add(itemizedLayer, layerGroup); - } - itemizedLayer.update(); - } - } - - //删除marker - public void removeMarker(MarkerItem markerItem) { - if (vectorLayerMap != null && vectorLayerMap.containsKey("Marker")) { - ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get("Marker"); - if (itemizedLayer.getItemList() != null && itemizedLayer.getItemList().size() > 0) { - itemizedLayer.removeItem(markerItem); - } - } - } - - /** - * @param markerItem marker - * @param layerName 图层 - */ - public void removeMarker(MarkerItem markerItem, String layerName) { - if (vectorLayerMap != null && layerName != null && vectorLayerMap.containsKey(layerName)) { - ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); - if (itemizedLayer.getItemList() != null && itemizedLayer.getItemList().size() > 0) { - itemizedLayer.removeItem(markerItem); - } - } - } - - - /** - * 在地图中心增加marker - */ - public void showEditMapGraphical(String geometry, int type) { - - } - - //增加marker - public MarkerItem addMarker(GeoPoint geopoint, Bitmap bitmap) { - if (geopoint != null && bitmap != null) { - - MarkerItem markerItem = new MarkerItem(StringUtil.Companion.createUUID(), "", geopoint.getLatitude() + "," + geopoint.getLongitude(), geopoint); - - MarkerSymbol markerSymbol = new MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); - - markerItem.setMarker(markerSymbol); - - addMarker2MarkerLayer(markerItem, bitmap, "", NIMapView.LAYER_GROUPS.OTHER.ordinal()); - - return markerItem; - } - - return null; - } - - public Location getCurrentLocation() { - return mCurrentLocation; - } - -} +//package com.navinfo.collect.library.map; +// +//import android.app.Activity; +//import android.content.Context; +//import android.graphics.BitmapFactory; +//import android.graphics.Color; +//import android.location.Location; +//import android.os.Environment; +//import android.text.TextPaint; +//import android.util.Log; +//import android.widget.TextView; +//import android.widget.Toast; +// +//import com.badlogic.gdx.maps.MapGroupLayer; +//import com.navinfo.collect.library.R; +//import com.navinfo.collect.library.map.layers.NIPolygonLayer; +//import com.navinfo.collect.library.map.source.NavinfoMapRastorTileSource; +//import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource; +//import com.navinfo.collect.library.utils.DistanceUtil; +//import com.navinfo.collect.library.utils.GeometryTools; +//import com.navinfo.collect.library.utils.StringUtil; +// +//import org.locationtech.jts.geom.Geometry; +//import org.locationtech.jts.geom.Polygon; +//import org.oscim.android.canvas.AndroidBitmap; +//import org.oscim.backend.CanvasAdapter; +//import org.oscim.backend.canvas.Bitmap; +//import org.oscim.core.GeoPoint; +//import org.oscim.core.MapPosition; +//import org.oscim.event.Event; +//import org.oscim.layers.Layer; +//import org.oscim.layers.LocationLayer; +//import org.oscim.layers.marker.ItemizedLayer; +//import org.oscim.layers.marker.MarkerInterface; +//import org.oscim.layers.marker.MarkerItem; +//import org.oscim.layers.marker.MarkerSymbol; +//import org.oscim.layers.tile.bitmap.BitmapTileLayer; +//import org.oscim.layers.tile.vector.VectorTileLayer; +//import org.oscim.layers.vector.geometries.Drawable; +//import org.oscim.layers.vector.geometries.PointDrawable; +//import org.oscim.layers.vector.geometries.PolygonDrawable; +//import org.oscim.layers.vector.PathLayer; +//import org.oscim.layers.vector.geometries.Style; +//import org.oscim.map.Map; +//import org.oscim.tiling.source.OkHttpEngine; +// +//import java.io.File; +//import java.math.BigDecimal; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +// +//import okhttp3.Cache; +//import okhttp3.OkHttpClient; +// +//public class NILayerManager implements ItemizedLayer.OnItemGestureListener { +// private Map vtmMap; +// public static String defaultDir = Environment.getExternalStorageDirectory() + "/" + "NavinfoCollect"; +// private String defaultLocalMapPath = defaultDir + "/maps/"; +// //图层管理 +// private java.util.Map layersMap = new HashMap(); +// //默认marker图层 +// private ItemizedLayer mDefaultMarkerLayer; +// //定位图层 +// private LocationLayer mLocationLayer; +// private NIPolygonLayer mPolygonLayer; +// private List mPathMakers = new ArrayList<>(); +// private Location mCurrentLocation; // 当前位置信息 +// +// public static final String MARQUEE_MARKER_LAYER = "MarqueeMarker"; +// +// private Context mCon; +// +// private java.util.Map vectorLayerMap; // 维护vector图层的map数据,key为图层名称(一般对应为矢量数据的数据源),value为图层 +// +// public NILayerManager(Context context, Map vtmMap) { +// this.vtmMap = vtmMap; +// this.mCon = context; +// +// //新增marker图标样式 +// AndroidBitmap mDefaultBitmap = +// new AndroidBitmap(BitmapFactory.decodeResource(context.getResources(), R.mipmap.marker)); +// MarkerSymbol markerSymbol = new MarkerSymbol(mDefaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); +// //新增marker图层 +// mDefaultMarkerLayer = new ItemizedLayer( +// vtmMap, +// new ArrayList(), +// markerSymbol, +// this +// ); +// addLayer("defaultMarkerLayer", mDefaultMarkerLayer, NIMapView.LAYER_GROUPS.VECTOR.ordinal()); +// +// //定位图层 +// mLocationLayer = new LocationLayer(vtmMap); +// addLayer("locationLayer", mLocationLayer, NIMapView.LAYER_GROUPS.ALLWAYS_SHOW_GROUP.ordinal()); +// +// if (this.vectorLayerMap == null) { +// this.vectorLayerMap = new HashMap<>(); +// } +// } +// +// public Layer getRasterTileLayer(Context mContext, String url, String tilePath, boolean useCache) { +// if (this.vtmMap == null) { +// throw new IllegalStateException("无法获取到map对象"); +// } +// OkHttpClient.Builder builder = new OkHttpClient.Builder(); +// NavinfoMapRastorTileSource mTileSource = NavinfoMapRastorTileSource.builder(url).tilePath(tilePath).httpFactory(new OkHttpEngine.OkHttpFactory(builder)).build(); +// // 如果使用缓存 +// if (useCache) { +// File cacheDirectory = new File(defaultDir, "tiles-raster"); +// int cacheSize = 300 * 1024 * 1024; // 300 MB +// Cache cache = new Cache(cacheDirectory, cacheSize); +// builder.cache(cache); +// } +// +//// mTileSource.setHttpEngine(new OkHttpEngine.OkHttpFactory(builder)); +//// mTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example")); +//// mTileSource.setCache(new TileCache(mContext, defaultDir, url.substring(url.indexOf(":")+1))); +// +// BitmapTileLayer rasterLayer = new BitmapTileLayer(this.vtmMap, mTileSource); +// return rasterLayer; +// } +// +// // 初始化请求在线底图数据 +// public Layer getDefaultVectorLayer(boolean useCache) { +// OkHttpClient.Builder builder = new OkHttpClient.Builder(); +// if (useCache) { +// // Cache the tiles into file system +// File cacheDirectory = new File(defaultDir, "tiles-vector"); +// int cacheSize = 200 * 1024 * 1024; // 200 MB +// Cache cache = new Cache(cacheDirectory, cacheSize); +// builder.cache(cache); +// } +// +// NavinfoMultiMapFileTileSource tileSource = NavinfoMultiMapFileTileSource.builder() +// .apiKey("4wTLZyXcQym31pxC_HGy7Q") // Put a proper API key +// .httpFactory(new OkHttpEngine.OkHttpFactory(builder)) +// //.locale("en") +// .build(); +// HashMap headerMap = new HashMap<>(); +// headerMap.put("token", "eyJhbGciOiJIUzI1NiJ9.eyJjbGllbnRJZCI6MTAzLCJ1c2VyTmFtZSI6ImFkbWluIiwidXNlcklkIjoxLCJ1c2VyR3JvdXAiOiLnoJTlj5Hpg6giLCJvcmdJZCI6MSwiaWF0IjoxNjMwOTk4MzI5LCJleHAiOjE2MzEwODQ3Mjl9.0wFm8mAA9dCC2FmZj-u1dhxTFDRYx8AqVnh2C88hitk"); +// tileSource.setHttpRequestHeaders(headerMap); +// VectorTileLayer l = new VectorTileLayer(this.vtmMap, tileSource); +// return l; +// } +// +// public void addLayer(String tag, Layer layer) { +// if (!layersMap.containsKey(tag)) { +// layersMap.put(tag, layer); +// vtmMap.layers().add(layer); +// } +// } +// +// +// public void addLayer(String tag, Layer layer, int group) { +// if (!layersMap.containsKey(tag)) { +// layersMap.put(tag, layer); +// vtmMap.layers().add(layer, group); +// } +// } +// +// public void addLayer(int index, String tag, Layer layer) { +// if (!layersMap.containsKey(tag)) { +// layersMap.put(tag, layer); +// vtmMap.layers().add(index, layer); +// } +// } +// +// public boolean containsLayer(String tag) { +// return layersMap.containsKey(tag); +// } +// +// public Layer getLayer(String tag) { +// return layersMap.get(tag); +// } +// +// public void removeLayer(String tag) { +// if (layersMap.containsKey(tag)) { +// Layer layer = layersMap.remove(tag); +// vtmMap.layers().remove(layer); +// } +// } +// +// /** +// * 返回默认marker图层 +// * +// * @return mDefaultMarkerLayer +// */ +// public ItemizedLayer getDefaultMarkerLayer() { +// return mDefaultMarkerLayer; +// } +// +// /** +// * 返回定位图层 +// * +// * @return mLocationLayer +// */ +// public LocationLayer getLocationLayer() { +// return mLocationLayer; +// } +// +// +// @Override +// public boolean onItemSingleTapUp(int index, Object item) { +// return false; +// } +// +// @Override +// public boolean onItemLongPress(int index, Object item) { +// return false; +// } +// +// /** +// * 定位 +// * @param lon +// * @param lat +// * @param time +// */ +// public void jumpToPosition(double lon, double lat, long time) { +// MapPosition mapPosition = vtmMap.getMapPosition(); +// mapPosition.setPosition(lat, lon); +// vtmMap.animator().animateTo(time, mapPosition); +// } +// +// /** +// * 定位 +// * @param lon +// * @param lat +// * @param zoomLevel +// */ +// public void jumpToPosition(double lon, double lat, int zoomLevel) { +// MapPosition mapPosition = vtmMap.getMapPosition(); +// if (mapPosition.getZoomLevel() < zoomLevel) { +// mapPosition.setZoomLevel(zoomLevel); +// } +// mapPosition.setPosition(lat, lon); +// vtmMap.animator().animateTo(300, mapPosition); +// } +// +// public void addMarker2MarkerLayer(MarkerInterface markerItem, Bitmap defaultBitmap, String layerName, int layerGroup) { +// if (markerItem == null) { +// return; +// } +// if (vectorLayerMap != null) { +// if (!vectorLayerMap.containsKey(layerName) || vectorLayerMap.get(layerName) == null) { +// MarkerSymbol symbol = new MarkerSymbol(defaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); +// vectorLayerMap.put(layerName, new ItemizedLayer(vtmMap, symbol)); +// } +// +// ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); +// itemizedLayer.addItem(markerItem); +// if (!vtmMap.layers().contains(itemizedLayer)) { +// vtmMap.layers().add(itemizedLayer, layerGroup); +// } +// itemizedLayer.update(); +// } +// } +// +// public void addMarker2MarkerLayer(MarkerInterface markerItem, Bitmap defaultBitmap, String layerName, int layerGroup, ItemizedLayer.OnItemGestureListener listener) { +// if (markerItem == null) { +// return; +// } +// if (vectorLayerMap != null) { +// if (!vectorLayerMap.containsKey(layerName) || vectorLayerMap.get(layerName) == null) { +// MarkerSymbol symbol = new MarkerSymbol(defaultBitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); +// vectorLayerMap.put(layerName, new ItemizedLayer(vtmMap, new ArrayList(), symbol, listener)); +// } +// +// ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); +// itemizedLayer.addItem(markerItem); +// if (!vtmMap.layers().contains(itemizedLayer)) { +// vtmMap.layers().add(itemizedLayer, layerGroup); +// } +// itemizedLayer.update(); +// } +// } +// +// //删除marker +// public void removeMarker(MarkerItem markerItem) { +// if (vectorLayerMap != null && vectorLayerMap.containsKey("Marker")) { +// ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get("Marker"); +// if (itemizedLayer.getItemList() != null && itemizedLayer.getItemList().size() > 0) { +// itemizedLayer.removeItem(markerItem); +// } +// } +// } +// +// /** +// * @param markerItem marker +// * @param layerName 图层 +// */ +// public void removeMarker(MarkerItem markerItem, String layerName) { +// if (vectorLayerMap != null && layerName != null && vectorLayerMap.containsKey(layerName)) { +// ItemizedLayer itemizedLayer = (ItemizedLayer) vectorLayerMap.get(layerName); +// if (itemizedLayer.getItemList() != null && itemizedLayer.getItemList().size() > 0) { +// itemizedLayer.removeItem(markerItem); +// } +// } +// } +// +// +// /** +// * 在地图中心增加marker +// */ +// public void showEditMapGraphical(String geometry, int type) { +// +// } +// +// //增加marker +// public MarkerItem addMarker(GeoPoint geopoint, Bitmap bitmap) { +// if (geopoint != null && bitmap != null) { +// +// MarkerItem markerItem = new MarkerItem(StringUtil.Companion.createUUID(), "", geopoint.getLatitude() + "," + geopoint.getLongitude(), geopoint); +// +// MarkerSymbol markerSymbol = new MarkerSymbol(bitmap, MarkerSymbol.HotspotPlace.BOTTOM_CENTER); +// +// markerItem.setMarker(markerSymbol); +// +// addMarker2MarkerLayer(markerItem, bitmap, "", NIMapView.LAYER_GROUPS.OTHER.ordinal()); +// +// return markerItem; +// } +// +// return null; +// } +// +// public Location getCurrentLocation() { +// return mCurrentLocation; +// } +// +//} diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/NILocation.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/NILocation.kt deleted file mode 100644 index deae88ce..00000000 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/NILocation.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.navinfo.collect.library.map - -import android.location.Location - - -class NILocation(provider: String) : Location(provider) { - var radius = 0f -} \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMap.java b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMap.java index 027d60b8..31de0aa2 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMap.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMap.java @@ -1,386 +1,330 @@ -package com.navinfo.collect.library.map; - -import android.graphics.Bitmap; -import android.graphics.Rect; -import android.view.MotionEvent; -import android.view.View; - -import com.navinfo.collect.library.utils.CacheTileProgress; -import com.navinfo.collect.library.utils.TileDownloader; -import com.yanzhenjie.kalle.Kalle; -import com.yanzhenjie.kalle.download.Download; - -import org.oscim.core.GeoPoint; -import org.oscim.core.MapPosition; -import org.oscim.layers.Layer; -import org.oscim.layers.tile.bitmap.BitmapTileLayer; -import org.oscim.map.Map; -import org.oscim.tiling.source.UrlTileSource; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; -import java.util.concurrent.ScheduledExecutorService; - -/** - * 定义 NavinfoMap 地图对象的操作方法与接口 - */ -public class NIMap { - /** - * - */ - private Map map; - /** - * 地图控件 - */ - private NIMapView mMapView; - /** - * 指北针显隐 - */ - private boolean enableCompassImage = true; - - /** - * 用户位置显示图层 - * */ -// private NaviLocationLayer locationLayer; - /** - * 构造函数 - */ - public NIMap(NIMapView niMapView) { - this.mMapView = niMapView; - this.map = mMapView.getVtmMap(); - } - - /** - * 获取地图的当前状态 - * - * @return - */ - public Map getVtmMap() { - return map; - } - - /** - * 获取地图最大缩放级别 - * - * @return - */ - public float getMaxZoomLevel() { - return map.viewport().getMaxZoomLevel(); - } - - /** - * 获取地图最小缩放级别 - * - * @return - */ - public float getMinZoomLevel() { - - return map.viewport().getMinZoomLevel(); - } - - /** - * 设置指南针是否显示 - * - * @param enable - */ - public void setCompassEnable(boolean enable) { - this.enableCompassImage = enable; - if (mMapView != null && mMapView.getCompassImage() != null) { - mMapView.getCompassImage().setVisibility(enable ? View.VISIBLE : View.GONE); - mMapView.getCompassImage().setEnabled(enable); - } - } - - /** - * 获取指北针显隐控制 - * - * @return true 显示 false 隐藏 - */ - public boolean isEnableCompassImage() { - return enableCompassImage; - } - - /** - * 设置指南针自定义图标 - * - * @param icon - */ - public void setCompassIcon(Bitmap icon) { - if (mMapView != null && mMapView.getCompassImage() != null) { - mMapView.getCompassImage().setImageBitmap(icon); - } - } - - - /** - * 设置地图显示大小等级 - * - * @param level - */ - public void setFontSizeLevel(int level) { - - } - - /** - * 设置地图最大以及最小缩放级别 - * - * @param max - * @param min - */ - public void setMaxAndMinZoomLevel(int max, int min) { - map.viewport().setMaxZoomLevel(max); - map.viewport().setMinZoomLevel(min); - } - - /** - * 放大 - * - * @param animate 是否动画过渡 - */ - public void zoomIn(boolean animate) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setZoom(mapPosition.getZoom() + 1); - if (animate) { - map.animator().animateTo(mapPosition); - } else { - map.setMapPosition(mapPosition); - } - } - - /** - * 缩小地图 - * - * @param animate 是否动画过渡 - */ - public void zoomOut(boolean animate) { - MapPosition mapPosition = map.getMapPosition(); - mapPosition.setZoom(mapPosition.getZoom() - 1); - if (animate) { - map.animator().animateTo(mapPosition); - } else { - map.setMapPosition(mapPosition); - } - } - - /** - * 设置定位数据, 只有先允许定位图层后设置数据才会生效,参见 setMyLocationEnabled(boolean) - * - * @param data - */ -// public void setMyLocationData(Location data) { -// if (locationLayer == null) { -// return; -// } -// locationLayer.setPosition(data.getLatitude(), data.getLongitude(), data.getAccuracy()); +//package com.navinfo.collect.library.map; +// +//import android.graphics.Bitmap; +//import android.graphics.Rect; +//import android.view.View; +// +//import com.navinfo.collect.library.utils.CacheTileProgress; +//import com.navinfo.collect.library.utils.TileDownloader; +//import com.yanzhenjie.kalle.download.Download; +// +//import org.oscim.core.GeoPoint; +//import org.oscim.core.MapPosition; +//import org.oscim.layers.Layer; +//import org.oscim.layers.tile.bitmap.BitmapTileLayer; +//import org.oscim.map.Map; +//import org.oscim.tiling.source.UrlTileSource; +// +//import java.util.ArrayList; +//import java.util.List; +//import java.util.concurrent.Callable; +//import java.util.concurrent.Executors; +//import java.util.concurrent.FutureTask; +//import java.util.concurrent.ScheduledExecutorService; +// +///** +// * 定义 NavinfoMap 地图对象的操作方法与接口 +// */ +//public class NIMap { +// /** +// * +// */ +// private Map map; +// /** +// * 地图控件 +// */ +// private NIMapView mMapView; +// /** +// * 指北针显隐 +// */ +// private boolean enableCompassImage = true; +// +// /** +// * 用户位置显示图层 +// * */ +//// private NaviLocationLayer locationLayer; +// +// /** +// * 构造函数 +// */ +// public NIMap(NIMapView niMapView) { +// this.mMapView = niMapView; +// this.map = mMapView.getVtmMap(); // } - -// public void setMyLocationData(double lat, double lon, float accuracy) { -// if (locationLayer == null) { -// return; -// } -// locationLayer.setPosition(lat, lon, accuracy); +// +// /** +// * 获取地图的当前状态 +// * +// * @return +// */ +// public Map getVtmMap() { +// return map; // } - - /** - * 设置是否允许定位图层 - * - * @param enabled - */ -// public void setMyLocationEnabled(Context mContext, boolean enabled) { -// initLocaitonLayer(mContext); -// locationLayer.setEnabled(enabled); +// +// /** +// * 获取地图最大缩放级别 +// * +// * @return +// */ +// public float getMaxZoomLevel() { +// return map.viewport().getMaxZoomLevel(); // } - -// private void initLocaitonLayer(Context mContext) { -// if (map == null) { -// throw new IllegalStateException("map不可用,无法显示当前位置!"); -// } -// if (locationLayer == null) { -// locationLayer = new NaviLocationLayer(mContext, map); +// +// /** +// * 获取地图最小缩放级别 +// * +// * @return +// */ +// public float getMinZoomLevel() { +// +// return map.viewport().getMinZoomLevel(); +// } +// +// /** +// * 设置指南针是否显示 +// * +// * @param enable +// */ +// public void setCompassEnable(boolean enable) { +// this.enableCompassImage = enable; +// if (mMapView != null && mMapView.getCompassImage() != null) { +// mMapView.getCompassImage().setVisibility(enable ? View.VISIBLE : View.GONE); +// mMapView.getCompassImage().setEnabled(enable); // } // } - - /** - * 设置地图 - * */ - public void setMapPosition(double latitude, double longitude, int zoomLevel) { - double scale = 1 << zoomLevel; - getVtmMap().setMapPosition(latitude, longitude, scale); - } - - public void animateMapPosition(double latitude, double longitude, int zoomLevel, int duration) { - if (duration < 0) { - duration = 500; - } - if (zoomLevel <= 0) { - zoomLevel = getVtmMap().getMapPosition().zoomLevel; - } - double scale = 1 << zoomLevel; - MapPosition mapPosition = new MapPosition(latitude, longitude, scale); - getVtmMap().animator().animateTo(duration, mapPosition); - } - - /** - * 下载离线矢量地图 - * */ - public void downloadVectorMap(String url, DownloadProgress downloadProgress) { - Kalle.Download.get(url).directory(NILayerManager.defaultDir).onProgress(new Download.ProgressBar() { - @Override - public void onProgress(int progress, long byteCount, long speed) { - downloadProgress.onProgress(progress, byteCount, speed); - } - }); - } - - /** - * 缓存urlTilesource对应的数据 - * */ - public List cacheUrlTileMap(Rect rect, int minZoomLevel, int maxZoomLevel, CacheTileProgress progress) { - List layerList = getVtmMap().layers(); - List urlTileSourceList = new ArrayList<>(); - if (layerList!=null&&!layerList.isEmpty()) { - for (int i = 0; i < layerList.size(); i++) { - Layer layer = layerList.get(i); - if (layer instanceof BitmapTileLayer && ((BitmapTileLayer) layer).getTileSource() instanceof UrlTileSource) { - UrlTileSource urlTileSource = (UrlTileSource) ((BitmapTileLayer) layer).getTileSource(); - urlTileSourceList.add(urlTileSource); - } - } - } - // 根据rect获取对应的地理坐标 - GeoPoint leftTopGeoPoint = map.viewport().fromScreenPoint(rect.left, rect.top); - GeoPoint rightBottomGeoPoint = map.viewport().fromScreenPoint(rect.right, rect.bottom); - ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); - List futureTaskList = new ArrayList<>(); - progress.setLayerCount(urlTileSourceList.size()); - for (int i = 0; i < urlTileSourceList.size(); i++) { - UrlTileSource urlTileSource = urlTileSourceList.get(i); - int finalI = i; - progress.setLayerId(i); - Callable callable = TileDownloader.getInstance().downloadRasterTile(urlTileSource, leftTopGeoPoint, rightBottomGeoPoint, (byte) minZoomLevel, (byte) maxZoomLevel, progress); - FutureTask futureTask = new FutureTask(callable); - futureTaskList.add(futureTask); - } - - if (futureTaskList!=null&&!futureTaskList.isEmpty()){ - for (int i = 0; i < futureTaskList.size(); i++) { - scheduledExecutorService.submit(futureTaskList.get(i)); - } - scheduledExecutorService.shutdown(); - } - return futureTaskList; - } - - public void cancelCacheTileMap() { - TileDownloader.getInstance().setCanDownloadRasterTile(false); - } - - public interface DownloadProgress { - - Download.ProgressBar DEFAULT = new Download.ProgressBar() { - @Override - public void onProgress(int progress, long byteCount, long speed) { - } - }; - - /** - * Download onProgress changes. - */ - void onProgress(int progress, long byteCount, long speed); - } - - /** - * 设置地图单击事件监听者 - * - * @param listener - */ - public void setOnMapClickListener(OnMapClickListener listener) { - mMapView.setOnMapClickListener(listener); - } - - /** - * 设置地图双击事件监听者 - * - * @param listener - */ - public void setOnMapDoubleClickListener(OnMapDoubleClickListener listener) { - mMapView.setOnMapDoubleClickListener(listener); - } - - /** - * 设置地图长按事件监听者 - * - * @param listener - */ - public void setOnMapLongClickListener(OnMapLongClickListener listener) { - mMapView.setOnMapLongClickListener(listener); - } - - /** - * @param listener - */ - public void setOnMapTouchListener(OnMapTouchListener listener) { - mMapView.setOnMapTouchListener(listener); - } - - /** - * 地图单击事件监听接口 - */ - public static interface OnMapClickListener { - /** - * 地图单击事件回调函数 - * - * @param point - */ - void onMapClick(GeoPoint point); - - /** - * 地图内 Poi 单击事件回调函数 - * - * @param poi - */ - void onMapPoiClick(GeoPoint poi); - } - - /** - * 地图双击事件监听接口 - */ - public static interface OnMapDoubleClickListener { - - /** - * 地图双击事件监听回调函数 - * - * @param point - */ - void onMapDoubleClick(GeoPoint point); - - } - - /** - * 地图长按事件监听接口 - */ - public static interface OnMapLongClickListener { - /** - * 地图长按事件监听回调函数 - * - * @param point - */ - void onMapLongClick(GeoPoint point); - } - - /** - * 用户触摸地图时回调接口 - */ - public static interface OnMapTouchListener { - /** - * 当用户触摸地图时回调函数 - * - * @param event - */ - void onTouch(MotionEvent event); - } - -} +// +// /** +// * 获取指北针显隐控制 +// * +// * @return true 显示 false 隐藏 +// */ +// public boolean isEnableCompassImage() { +// return enableCompassImage; +// } +// +// /** +// * 设置指南针自定义图标 +// * +// * @param icon +// */ +// public void setCompassIcon(Bitmap icon) { +// if (mMapView != null && mMapView.getCompassImage() != null) { +// mMapView.getCompassImage().setImageBitmap(icon); +// } +// } +// +// +// /** +// * 设置地图显示大小等级 +// * +// * @param level +// */ +// public void setFontSizeLevel(int level) { +// +// } +// +// /** +// * 设置地图最大以及最小缩放级别 +// * +// * @param max +// * @param min +// */ +// public void setMaxAndMinZoomLevel(int max, int min) { +// map.viewport().setMaxZoomLevel(max); +// map.viewport().setMinZoomLevel(min); +// } +// +// /** +// * 放大 +// * +// * @param animate 是否动画过渡 +// */ +// public void zoomIn(boolean animate) { +// MapPosition mapPosition = map.getMapPosition(); +// mapPosition.setZoom(mapPosition.getZoom() + 1); +// if (animate) { +// map.animator().animateTo(mapPosition); +// } else { +// map.setMapPosition(mapPosition); +// } +// } +// +// /** +// * 缩小地图 +// * +// * @param animate 是否动画过渡 +// */ +// public void zoomOut(boolean animate) { +// MapPosition mapPosition = map.getMapPosition(); +// mapPosition.setZoom(mapPosition.getZoom() - 1); +// if (animate) { +// map.animator().animateTo(mapPosition); +// } else { +// map.setMapPosition(mapPosition); +// } +// } +// +// /** +// * 设置定位数据, 只有先允许定位图层后设置数据才会生效,参见 setMyLocationEnabled(boolean) +// * +// * @param data +// */ +//// public void setMyLocationData(Location data) { +//// if (locationLayer == null) { +//// return; +//// } +//// locationLayer.setPosition(data.getLatitude(), data.getLongitude(), data.getAccuracy()); +//// } +// +//// public void setMyLocationData(double lat, double lon, float accuracy) { +//// if (locationLayer == null) { +//// return; +//// } +//// locationLayer.setPosition(lat, lon, accuracy); +//// } +// +// /** +// * 设置是否允许定位图层 +// * +// * @param enabled +// */ +//// public void setMyLocationEnabled(Context mContext, boolean enabled) { +//// initLocaitonLayer(mContext); +//// locationLayer.setEnabled(enabled); +//// } +// +//// private void initLocaitonLayer(Context mContext) { +//// if (map == null) { +//// throw new IllegalStateException("map不可用,无法显示当前位置!"); +//// } +//// if (locationLayer == null) { +//// locationLayer = new NaviLocationLayer(mContext, map); +//// } +//// } +// +// /** +// * 设置地图 +// */ +// public void setMapPosition(double latitude, double longitude, int zoomLevel) { +// double scale = 1 << zoomLevel; +// getVtmMap().setMapPosition(latitude, longitude, scale); +// } +// +// public void animateMapPosition(double latitude, double longitude, int zoomLevel, int duration) { +// if (duration < 0) { +// duration = 500; +// } +// if (zoomLevel <= 0) { +// zoomLevel = getVtmMap().getMapPosition().zoomLevel; +// } +// double scale = 1 << zoomLevel; +// MapPosition mapPosition = new MapPosition(latitude, longitude, scale); +// getVtmMap().animator().animateTo(duration, mapPosition); +// } +// +//// /** +//// * 下载离线矢量地图 +//// * */ +//// public void downloadVectorMap(String url, DownloadProgress downloadProgress) { +//// Kalle.Download.get(url).directory(NILayerManager.defaultDir).onProgress(new Download.ProgressBar() { +//// @Override +//// public void onProgress(int progress, long byteCount, long speed) { +//// downloadProgress.onProgress(progress, byteCount, speed); +//// } +//// }); +//// } +// +// /** +// * 缓存urlTilesource对应的数据 +// */ +// public List cacheUrlTileMap(Rect rect, int minZoomLevel, int maxZoomLevel, CacheTileProgress progress) { +// List layerList = getVtmMap().layers(); +// List urlTileSourceList = new ArrayList<>(); +// if (layerList != null && !layerList.isEmpty()) { +// for (int i = 0; i < layerList.size(); i++) { +// Layer layer = layerList.get(i); +// if (layer instanceof BitmapTileLayer && ((BitmapTileLayer) layer).getTileSource() instanceof UrlTileSource) { +// UrlTileSource urlTileSource = (UrlTileSource) ((BitmapTileLayer) layer).getTileSource(); +// urlTileSourceList.add(urlTileSource); +// } +// } +// } +// // 根据rect获取对应的地理坐标 +// GeoPoint leftTopGeoPoint = map.viewport().fromScreenPoint(rect.left, rect.top); +// GeoPoint rightBottomGeoPoint = map.viewport().fromScreenPoint(rect.right, rect.bottom); +// ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); +// List futureTaskList = new ArrayList<>(); +// progress.setLayerCount(urlTileSourceList.size()); +// for (int i = 0; i < urlTileSourceList.size(); i++) { +// UrlTileSource urlTileSource = urlTileSourceList.get(i); +// int finalI = i; +// progress.setLayerId(i); +// Callable callable = TileDownloader.getInstance().downloadRasterTile(urlTileSource, leftTopGeoPoint, rightBottomGeoPoint, (byte) minZoomLevel, (byte) maxZoomLevel, progress); +// FutureTask futureTask = new FutureTask(callable); +// futureTaskList.add(futureTask); +// } +// +// if (futureTaskList != null && !futureTaskList.isEmpty()) { +// for (int i = 0; i < futureTaskList.size(); i++) { +// scheduledExecutorService.submit(futureTaskList.get(i)); +// } +// scheduledExecutorService.shutdown(); +// } +// return futureTaskList; +// } +// +// public void cancelCacheTileMap() { +// TileDownloader.getInstance().setCanDownloadRasterTile(false); +// } +// +// public interface DownloadProgress { +// +// Download.ProgressBar DEFAULT = new Download.ProgressBar() { +// @Override +// public void onProgress(int progress, long byteCount, long speed) { +// } +// }; +// +// /** +// * Download onProgress changes. +// */ +// void onProgress(int progress, long byteCount, long speed); +// } +// +// /** +// * 设置地图单击事件监听者 +// * +// * @param listener +// */ +// public void setOnMapClickListener(OnMapClickListener listener) { +// mMapView.setOnMapClickListener(listener); +// } +// +// /** +// * 设置地图双击事件监听者 +// * +// * @param listener +// */ +// public void setOnMapDoubleClickListener(OnMapDoubleClickListener listener) { +// mMapView.setOnMapDoubleClickListener(listener); +// } +// +// /** +// * 设置地图长按事件监听者 +// * +// * @param listener +// */ +// public void setOnMapLongClickListener(OnMapLongClickListener listener) { +// mMapView.setOnMapLongClickListener(listener); +// } +// +// /** +// * @param listener +// */ +// public void setOnMapTouchListener(OnMapTouchListener listener) { +// mMapView.setOnMapTouchListener(listener); +// } +// +// +// +//} diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapController.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapController.kt index 10343786..05f8cb44 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapController.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapController.kt @@ -1,6 +1,7 @@ package com.navinfo.collect.library.map import android.content.Context +import com.navinfo.collect.library.data.entity.LayerManager import com.navinfo.collect.library.map.handler.* import com.navinfo.collect.library.map.maphandler.MeasureLayerHandler import com.navinfo.collect.library.map.handler.ViewportHandler @@ -15,35 +16,16 @@ open class NIMapController( mapView: NIMapView? = null, ) { private val mContext = context - internal var mMapView: NIMapView = - mapView ?: NIMapView(mContext, options) + var mMapView: NIMapView = mapView ?: NIMapView(mContext, options) - val animationHandler: AnimationHandler by lazy { AnimationHandler(mContext, mMapView) } - val markerHandle: MarkHandler by lazy { MarkHandler(mContext, mMapView) } - val locationLayerHandler: LocationLayerHandler by lazy { - LocationLayerHandler( - mContext, - mMapView - ) - }; - val lineHandler: LineHandler by lazy { LineHandler(mContext, mMapView) }; - val polygonHandler: PolygonHandler by lazy { PolygonHandler(mContext, mMapView) }; - val viewportHandler: ViewportHandler by lazy { ViewportHandler(mContext, mMapView) } - val measureLayerHandler: MeasureLayerHandler by lazy { MeasureLayerHandler(mContext, mMapView) }; + val layerManagerHandler = LayerManagerHandler(mContext, mMapView) + val locationLayerHandler by lazy { LocationLayerHandler(mContext, mMapView) } + val animationHandler by lazy { AnimationHandler(mContext, mMapView) } + val markerHandle by lazy { MarkHandler(mContext, mMapView) } + val lineHandler by lazy { LineHandler(mContext, mMapView) } + val polygonHandler by lazy { PolygonHandler(mContext, mMapView) } + val viewportHandler by lazy { ViewportHandler(mContext, mMapView) } + val measureLayerHandler by lazy { MeasureLayerHandler(mContext, mMapView) } - - /** - * 刷新地图 - */ - fun upDateMap(redraw: Boolean = true) { - if (redraw) { - mMapView.vtmMap.events.fire(org.oscim.map.Map.CLEAR_EVENT, mMapView.vtmMap.mapPosition) - } - mMapView.vtmMap.updateMap(redraw) - } - - open fun release() { - mMapView.onDestroy() - } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapView.java b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapView.java index 9e356227..fc22e203 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapView.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/NIMapView.java @@ -47,6 +47,8 @@ import org.oscim.tiling.source.mapfile.MultiMapFileTileSource; import java.io.File; + + /** * 一个显示地图的视图(View)。它负责从服务端获取地图数据。它将会捕捉屏幕触控手势事件 */ @@ -93,14 +95,82 @@ public final class NIMapView extends RelativeLayout { /** * 地图图层管理器 */ - private NILayerManager mLayerManager; - private Layer baseRasterLayer, defaultVectorTileLayer, defaultVectorLabelLayer, gridLayer; +// private NILayerManager mLayerManager; +// private Layer baseRasterLayer, defaultVectorTileLayer, defaultVectorLabelLayer, gridLayer; + /** + * 地图网格图层 + */ +// private Layer gridLayer; + protected Context mContext; + /** + * 地图状态信息 + */ private MapPreferences mPrefs; - protected String mapFilePath = Constant.ROOT_PATH+"/map"; + // protected String mapFilePath = Constant.ROOT_PATH + "/map"; protected GroupLayer baseGroupLayer; // 用于盛放所有基础底图的图层组,便于统一管理 + + /** + * 地图单击事件监听接口 + */ + public interface OnMapClickListener { + /** + * 地图单击事件回调函数 + * + * @param point + */ + void onMapClick(GeoPoint point); + + /** + * 地图内 Poi 单击事件回调函数 + * + * @param poi + */ + void onMapPoiClick(GeoPoint poi); + } + + /** + * 地图双击事件监听接口 + */ + public interface OnMapDoubleClickListener { + + /** + * 地图双击事件监听回调函数 + * + * @param point + */ + void onMapDoubleClick(GeoPoint point); + + } + + /** + * 地图长按事件监听接口 + */ + public interface OnMapLongClickListener { + /** + * 地图长按事件监听回调函数 + * + * @param point + */ + void onMapLongClick(GeoPoint point); + } + + /** + * 用户触摸地图时回调接口 + */ + public interface OnMapTouchListener { + /** + * 当用户触摸地图时回调函数 + * + * @param event + */ + void onTouch(MotionEvent event); + } + + + public NIMapView(Context context, NIMapOptions options) { this(context, null, 0); this.options = options; @@ -110,22 +180,22 @@ public final class NIMapView extends RelativeLayout { /** * 地图的单击事件监听 */ - private NIMap.OnMapClickListener mapClickListener; + private OnMapClickListener mapClickListener; /** * 地图的双击事件监听 */ - private NIMap.OnMapDoubleClickListener mapDoubleClickListener; + private OnMapDoubleClickListener mapDoubleClickListener; /** * 地图的长按事件监听 */ - private NIMap.OnMapLongClickListener mapLongClickListener; + private OnMapLongClickListener mapLongClickListener; /** * 地图的触摸事件 */ - private NIMap.OnMapTouchListener touchListener; + private OnMapTouchListener touchListener; public NIMapView(Context context, AttributeSet attrs) { this(context, attrs, 0); @@ -148,8 +218,7 @@ public final class NIMapView extends RelativeLayout { // map = new NIMap(this); compassImage = rootView.findViewById(R.id.navinfo_map_compass); initMapGroup(); // 初始化图层组 - - mLayerManager = new NILayerManager(context, getVtmMap()); +// mLayerManager = new NILayerManager(context, getVtmMap()); logoImage = rootView.findViewById(R.id.navinfo_map_logo); mRotateAnimation = new NIRotateAnimation(compassImage); @@ -183,11 +252,11 @@ public final class NIMapView extends RelativeLayout { NaviMapScaleBar naviMapScaleBar = new NaviMapScaleBar(getVtmMap()); naviMapScaleBar.initScaleBarLayer(GLViewport.Position.BOTTOM_LEFT, 25, 60); - if (gridLayer == null) { - gridLayer = new TileGridLayer(getVtmMap()); - getVtmMap().layers().add(gridLayer, LAYER_GROUPS.ALLWAYS_SHOW_GROUP.groupIndex); - gridLayer.setEnabled(false); - } +// if (gridLayer == null) { +// gridLayer = new TileGridLayer(getVtmMap()); +// getVtmMap().layers().add(gridLayer, LAYER_GROUPS.NAVIGATION.groupIndex); +//// gridLayer.setEnabled(true); +// } compassImage.setOnClickListener(new OnClickListener() { @Override @@ -229,9 +298,53 @@ public final class NIMapView extends RelativeLayout { }); zoomLayout = rootView.findViewById(R.id.navinfo_map_zoom_layer); - initMap(); + switchTileVectorLayerTheme(MAP_THEME.DEFAULT); } + + /** + * 切换 矢量图层 style + */ + + public void switchTileVectorLayerTheme(MAP_THEME styleId) { + // 如果不包含vectorlayer,则设置theme无效 + boolean bHis = false; + for (Layer layer : getVtmMap().layers()) { + if (layer instanceof VectorTileLayer) { + bHis = true; + break; + } + } + if (!bHis) { + updateMap(true); + return; + } + + if (styleId == null) { + getVtmMap().setTheme(new AssetsRenderTheme(mContext.getAssets(), "", "navdefault.xml"), true); + } else { + switch (styleId) { + case NEWTRON: + getVtmMap().setTheme(VtmThemes.NEWTRON, true); + break; + case OSMAGRAY: + getVtmMap().setTheme(VtmThemes.OSMAGRAY, true); + break; + case OSMARENDER: + getVtmMap().setTheme(VtmThemes.OSMARENDER, true); + break; + case TRONRENDER: + getVtmMap().setTheme(VtmThemes.TRONRENDER, true); + break; + default: + getVtmMap().setTheme(new AssetsRenderTheme(mContext.getAssets(), "", "editormarker.xml"), true); + break; + } + } + updateMap(); + } + + /** * 地图初始化参数 */ @@ -250,197 +363,177 @@ public final class NIMapView extends RelativeLayout { } - /** - * 初始化地图 - */ - private void initMap() { - switchBaseMapType(BASE_MAP_TYPE.CYCLE_MAP); - switchTileVectorLayerTheme(MAP_THEME.DEFAULT); - initVectorTileLayer(); - initMapLifeSource(); - } +// /** +// * 增加作业渲染 +// */ +// LabelLayer labelLayer; +// /** +// * 作业数据图层 +// */ +// VectorTileLayer vectorTileLayer; +// /** +// * 作业数据渲染图层 +// */ +// MapLifeDBTileSource mapLifeDBTileSource; +// /** +// * 轨迹渲染图层 +// */ +// MapLifeNiLocationTileSource mapLifeNiLocationTileSource; +// /** +// * 轨迹数据图层 +// */ +// VectorTileLayer vectorNiLocationTileLayer; +// /** +// * 增加作业渲染 +// */ +// LabelLayer labelNiLocationLayer; + +// public void initMapLifeSource() { +// mapLifeDBTileSource = new MapLifeDBTileSource(this.mContext, Constant.ROOT_PATH + "/coremap.db"); +// mapLifeNiLocationTileSource = new MapLifeNiLocationTileSource(this.mContext, Constant.ROOT_PATH + "/coremap.db"); +// vectorTileLayer = new VectorTileLayer(mapView.map(), mapLifeDBTileSource); +// vectorNiLocationTileLayer = new VectorTileLayer(mapView.map(), mapLifeNiLocationTileSource); +// mapView.map().layers().add(vectorNiLocationTileLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// mapView.map().layers().add(vectorTileLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// labelLayer = new LabelLayer(mapView.map(), vectorTileLayer, new LabelTileLoaderHook(), 15); +// mapView.map().layers().add(labelLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// labelNiLocationLayer = new LabelLayer(mapView.map(), vectorNiLocationTileLayer, new LabelTileLoaderHook(), 15); +// mapView.map().layers().add(labelNiLocationLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// +// switchTileVectorLayerTheme(null); +// mapView.map().updateMap(true); +// MapPosition mapPosition = new MapPosition(); +// mapPosition.setZoomLevel(18); +// mapPosition.setPosition(40.091692296269144, 116.26712172082546); +// //116.26712172082546 40.091692296269144 +// mapView.map().animator().animateTo(mapPosition); +// } +// +// public void dataLayerUpdate() { +// switchTileVectorLayerTheme(null); +// } /** - * 增加作业渲染 + * 初始化地图图层分组 */ - LabelLayer labelLayer; - /** - * 作业数据图层 - */ - VectorTileLayer vectorTileLayer; - /** - * 作业数据渲染图层 - */ - MapLifeDBTileSource mapLifeDBTileSource; - /** - * 轨迹渲染图层 - */ - MapLifeNiLocationTileSource mapLifeNiLocationTileSource; - /** - * 轨迹数据图层 - */ - VectorTileLayer vectorNiLocationTileLayer; - /** - * 增加作业渲染 - */ - LabelLayer labelNiLocationLayer; - - public void initMapLifeSource() { - mapLifeDBTileSource = new MapLifeDBTileSource(this.mContext, Constant.ROOT_PATH + "/coremap.db"); - mapLifeNiLocationTileSource = new MapLifeNiLocationTileSource(this.mContext,Constant.ROOT_PATH + "/coremap.db"); - vectorTileLayer = new VectorTileLayer(mapView.map(), mapLifeDBTileSource); - vectorNiLocationTileLayer = new VectorTileLayer(mapView.map(),mapLifeNiLocationTileSource); - mapView.map().layers().add(vectorNiLocationTileLayer,LAYER_GROUPS.VECTOR_TILE.groupIndex); - mapView.map().layers().add(vectorTileLayer,LAYER_GROUPS.VECTOR_TILE.groupIndex); - labelLayer = new LabelLayer(mapView.map(), vectorTileLayer, new LabelTileLoaderHook(), 15); - mapView.map().layers().add(labelLayer,LAYER_GROUPS.VECTOR_TILE.groupIndex); - labelNiLocationLayer = new LabelLayer(mapView.map(), vectorNiLocationTileLayer, new LabelTileLoaderHook(), 15); - mapView.map().layers().add(labelNiLocationLayer,LAYER_GROUPS.VECTOR_TILE.groupIndex); - - switchTileVectorLayerTheme(null); - mapView.map().updateMap(true); - MapPosition mapPosition = new MapPosition(); - mapPosition.setZoomLevel(18); - mapPosition.setPosition(40.091692296269144, 116.26712172082546); - //116.26712172082546 40.091692296269144 - mapView.map().animator().animateTo(mapPosition); - } - - public void dataLayerUpdate() { - switchTileVectorLayerTheme(null); - } - private void initMapGroup() { for (LAYER_GROUPS groups : LAYER_GROUPS.values()) { getVtmMap().layers().addGroup(groups.groupIndex); } } - /** - * 切换基础底图样式 - */ - public void switchBaseMapType(BASE_MAP_TYPE type) { - if (baseRasterLayer != null) { - getVtmMap().layers().remove(baseRasterLayer); - baseRasterLayer = null; - getVtmMap().updateMap(); - } - baseRasterLayer = mLayerManager.getRasterTileLayer(mContext, type.url, type.tilePath, true); - getVtmMap().layers().add(baseRasterLayer, LAYER_GROUPS.BASE_RASTER.groupIndex); - getVtmMap().updateMap(); - } - /** - * 移除基础底图样式 - */ - public void removeBaseMap() { - if (baseRasterLayer != null) { - getVtmMap().layers().remove(baseRasterLayer); - baseRasterLayer = null; - getVtmMap().updateMap(); - } - } +// /** +// * 移除基础底图样式 +// */ +// public void removeBaseMap() { +// if (baseRasterLayer != null) { +// getVtmMap().layers().remove(baseRasterLayer); +// baseRasterLayer = null; +// getVtmMap().updateMap(); +// } +// } - public void initVectorTileLayer(){ - if (baseGroupLayer == null) { - baseGroupLayer = new GroupLayer(getVtmMap()); - } - for (Layer layer : baseGroupLayer.layers) { - getVtmMap().layers().remove(layer); - } - baseGroupLayer.layers.clear(); +// private void initVectorTileLayer() { +// if (baseGroupLayer == null) { +// baseGroupLayer = new GroupLayer(getVtmMap()); +// } +// for (Layer layer : baseGroupLayer.layers) { +// getVtmMap().layers().remove(layer); +// } +// baseGroupLayer.layers.clear(); +// +// File baseMapFolder = new File(mapFilePath); +// if (!baseMapFolder.exists()) { +// return; +// } +// +// File[] mapFileList = baseMapFolder.listFiles(); +// +// if (mapFileList != null && mapFileList.length > 0) { +// +// MultiMapFileTileSource multiMapFileTileSource = new MultiMapFileTileSource(); +// +// for (File mapFile : mapFileList) { +// +// if (!mapFile.exists() || !mapFile.getName().endsWith(".map")) { +// continue; +// } +// +// MapFileTileSource mTileSource = new MapFileTileSource(); +// +// mTileSource.setPreferredLanguage("zh"); +// +// if (mTileSource.setMapFile(mapFile.getAbsolutePath())) { +// multiMapFileTileSource.add(mTileSource); +// } +// +// } +// +// VectorTileLayer baseMapLayer = new OsmTileLayer(getVtmMap()); +// baseMapLayer.setTileSource(multiMapFileTileSource); +// +// baseGroupLayer.layers.add(baseMapLayer); +// +// if (getTheme(null) != null) +// baseMapLayer.setTheme(getTheme(null)); +// +// baseGroupLayer.layers.add(new BuildingLayer(getVtmMap(), baseMapLayer)); +// baseGroupLayer.layers.add(new LabelLayer(getVtmMap(), baseMapLayer)); +// +// for (Layer layer : baseGroupLayer.layers) { +// if (layer instanceof LabelLayer) { +// getVtmMap().layers().add(layer, LAYER_GROUPS.VECTOR.groupIndex); +// } else { +// getVtmMap().layers().add(layer, LAYER_GROUPS.BASE_VECTOR.groupIndex); +// } +// } +// } +// } - File baseMapFolder = new File(mapFilePath); - if (!baseMapFolder.exists()) { - return; - } +// //获取渲染资源 +// public IRenderTheme getTheme(final String styleId) { +// AssetsRenderTheme theme = new AssetsRenderTheme(mContext.getAssets(), null, "default.xml"); +// if (styleId == null || "".equals(styleId.trim())) { +// switch (2) { +// case 0: +// theme = new AssetsRenderTheme(mContext.getAssets(), null, "default.xml"); +// break; +// case 1: +// theme = new AssetsRenderTheme(mContext.getAssets(), null, "osmarender.xml"); +// break; +// case 2: +// theme = new AssetsRenderTheme(mContext.getAssets(), null, "tronrender.xml"); +// break; +// } +// +// } +// +// return ThemeLoader.load(theme); +// } - File[] mapFileList = baseMapFolder.listFiles(); +// public void addDefaultVectorTileLayer(MAP_THEME theme) { +// if (defaultVectorTileLayer != null) { +// getVtmMap().layers().remove(defaultVectorTileLayer); +// defaultVectorTileLayer = null; +// getVtmMap().updateMap(); +// } +// defaultVectorTileLayer = mLayerManager.getDefaultVectorLayer(true); +// getVtmMap().layers().add(defaultVectorTileLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// defaultVectorLabelLayer = new LabelLayer(getVtmMap(), (VectorTileLayer) defaultVectorTileLayer); +// getVtmMap().layers().add(defaultVectorLabelLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); +// if (theme != null) { +//// switchTileVectorLayerTheme(theme); +// } +// getVtmMap().updateMap(); +// } - if (mapFileList != null && mapFileList.length > 0) { - - MultiMapFileTileSource multiMapFileTileSource = new MultiMapFileTileSource(); - - for (File mapFile : mapFileList) { - - if (!mapFile.exists() || !mapFile.getName().endsWith(".map")) { - continue; - } - - MapFileTileSource mTileSource = new MapFileTileSource(); - - mTileSource.setPreferredLanguage("zh"); - - if (mTileSource.setMapFile(mapFile.getAbsolutePath())) { - multiMapFileTileSource.add(mTileSource); - } - - } - - VectorTileLayer baseMapLayer = new OsmTileLayer(getVtmMap()); - baseMapLayer.setTileSource(multiMapFileTileSource); - - baseGroupLayer.layers.add(baseMapLayer); - - if (getTheme(null) != null) - baseMapLayer.setTheme(getTheme(null)); - - baseGroupLayer.layers.add(new BuildingLayer(getVtmMap(), baseMapLayer)); - baseGroupLayer.layers.add(new LabelLayer(getVtmMap(), baseMapLayer)); - - for (Layer layer : baseGroupLayer.layers) { - if (layer instanceof LabelLayer) { - getVtmMap().layers().add(layer, LAYER_GROUPS.VECTOR.groupIndex); - } else { - getVtmMap().layers().add(layer, LAYER_GROUPS.BASE_VECTOR.groupIndex); - } - } - } - } - - //获取渲染资源 - public IRenderTheme getTheme(final String styleId) { - AssetsRenderTheme theme = new AssetsRenderTheme(mContext.getAssets(), null, "default.xml"); - if (styleId == null || "".equals(styleId.trim())) { - switch (2) { - case 0: - theme = new AssetsRenderTheme(mContext.getAssets(), null, "default.xml"); - break; - case 1: - theme = new AssetsRenderTheme(mContext.getAssets(), null, "osmarender.xml"); - break; - case 2: - theme = new AssetsRenderTheme(mContext.getAssets(), null, "tronrender.xml"); - break; - } - - } - - return ThemeLoader.load(theme); - } - - public void addDefaultVectorTileLayer(MAP_THEME theme) { - if (defaultVectorTileLayer != null) { - getVtmMap().layers().remove(defaultVectorTileLayer); - defaultVectorTileLayer = null; - getVtmMap().updateMap(); - } - defaultVectorTileLayer = mLayerManager.getDefaultVectorLayer(true); - getVtmMap().layers().add(defaultVectorTileLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); - defaultVectorLabelLayer = new LabelLayer(getVtmMap(), (VectorTileLayer) defaultVectorTileLayer); - getVtmMap().layers().add(defaultVectorLabelLayer, LAYER_GROUPS.VECTOR_TILE.groupIndex); - if (theme != null) { - switchTileVectorLayerTheme(theme); - } - getVtmMap().updateMap(); - } - - public void setBaseRasterVisiable(boolean visiable) { - if (baseRasterLayer != null) { - baseRasterLayer.setEnabled(visiable); - getVtmMap().updateMap(); - } - } +// public void setBaseRasterVisiable(boolean visiable) { +// if (baseRasterLayer != null) { +// baseRasterLayer.setEnabled(visiable); +// getVtmMap().updateMap(); +// } +// } /** * 基础 @@ -473,24 +566,26 @@ public final class NIMapView extends RelativeLayout { } } - /** - * 网格图层是否显示 - */ - public void setGridLayerVisiable(boolean visiable) { - if (gridLayer != null) { - gridLayer.setEnabled(visiable); - getVtmMap().updateMap(); - } - } +// /** +// * 网格图层是否显示 +// */ +// public void setGridLayerVisiable(boolean visiable) { +// if (gridLayer != null) { +// gridLayer.setEnabled(visiable); +// updateMap(); +// } +// } /** * 图层组定义 */ public enum LAYER_GROUPS { - BASE_RASTER(0)/*栅格底图*/, BASE_VECTOR(1)/*矢量底图*/, - RASTER_TILE(2)/*栅格网格*/, VECTOR_TILE(3)/*矢量网格*/, - VECTOR(4)/*矢量图层组*/, OTHER(5)/*其他图层*/, - ALLWAYS_SHOW_GROUP(6), OPERATE(7)/*操作图层组*/; + BASE(0)/*底图图层组*/, + VECTOR_TILE(1)/*矢量瓦片组*/, + VECTOR(2)/*高亮组*/, + OPERATE(3)/*操作图层组*/, + NAVIGATION(4)/*定位导航组*/; + int groupIndex; LAYER_GROUPS(int groupIndex) { @@ -552,7 +647,7 @@ public final class NIMapView extends RelativeLayout { * @param bundle */ public void onSaveInstanceState(Bundle bundle) { - + super.onSaveInstanceState(); } @@ -560,11 +655,11 @@ public final class NIMapView extends RelativeLayout { * 当Activity销毁时调用地图的销毁 */ public void onDestroy() { - try{ + try { if (mapView != null) { mapView.onDestroy(); } - }catch (Exception e){ + } catch (Exception e) { } } @@ -627,9 +722,9 @@ public final class NIMapView extends RelativeLayout { public void zoomIn(View view) { if (view != null) { if (view.isEnabled()) { - MapPosition mapPosition = mapView.map().getMapPosition(); + MapPosition mapPosition = getVtmMap().getMapPosition(); mapPosition.setZoom(mapPosition.getZoom() + 1); - mapView.map().animator().animateTo(mapPosition); + getVtmMap().animator().animateTo(mapPosition); // map.zoomIn(true); } view.setEnabled(false); @@ -648,9 +743,9 @@ public final class NIMapView extends RelativeLayout { public void zoomOut(View view) { if (view != null) { if (view.isEnabled()) { - MapPosition mapPosition = mapView.map().getMapPosition(); + MapPosition mapPosition = getVtmMap().getMapPosition(); mapPosition.setZoom(mapPosition.getZoom() - 1); - mapView.map().animator().animateTo(mapPosition); + getVtmMap().animator().animateTo(mapPosition); // map.zoomOut(true); } @@ -809,47 +904,9 @@ public final class NIMapView extends RelativeLayout { } } - public void switchTileVectorLayerTheme(MAP_THEME styleId) { - // 如果不包含vectorlayer,则设置theme无效 - boolean bHis = false; - for (Layer layer : getVtmMap().layers()) { - if (layer instanceof VectorTileLayer) { - bHis = true; - break; - } - } - if (!bHis) { - getVtmMap().updateMap(true); - return; - } - - if (styleId == null) { - getVtmMap().setTheme(new AssetsRenderTheme(mContext.getAssets(), "", "navdefault.xml"), true); - } else { - switch (styleId) { - case NEWTRON: - getVtmMap().setTheme(VtmThemes.NEWTRON, true); - break; - case OSMAGRAY: - getVtmMap().setTheme(VtmThemes.OSMAGRAY, true); - break; - case OSMARENDER: - getVtmMap().setTheme(VtmThemes.OSMARENDER, true); - break; - case TRONRENDER: - getVtmMap().setTheme(VtmThemes.TRONRENDER, true); - break; - default: - getVtmMap().setTheme(new AssetsRenderTheme(mContext.getAssets(), "", "editormarker.xml"), true); - break; - } - } - getVtmMap().updateMap(); - } - - public NILayerManager getLayerManager() { - return mLayerManager; - } +// public NILayerManager getLayerManager() { +// return mLayerManager; +// } // 地图点击事件对应的图层 private class MapEventsReceiver extends Layer implements GestureListener { @@ -874,7 +931,7 @@ public final class NIMapView extends RelativeLayout { mapLongClickListener.onMapLongClick(geoPoint); } } - setOnMapClickListener(new NIMap.OnMapClickListener() { + setOnMapClickListener(new OnMapClickListener() { @Override public void onMapClick(GeoPoint point) { @@ -892,7 +949,7 @@ public final class NIMapView extends RelativeLayout { /** * 设置地图的点击事件 */ - public void setOnMapClickListener(@Nullable NIMap.OnMapClickListener listener) { + public void setOnMapClickListener(@Nullable OnMapClickListener listener) { this.mapClickListener = listener; } @@ -900,7 +957,7 @@ public final class NIMapView extends RelativeLayout { * 设置地图的双击事件 * 注:默认情况下,双击会自动放大地图 */ - public void setOnMapDoubleClickListener(@Nullable NIMap.OnMapDoubleClickListener listener) { + public void setOnMapDoubleClickListener(@Nullable OnMapDoubleClickListener listener) { this.mapDoubleClickListener = listener; } @@ -909,7 +966,7 @@ public final class NIMapView extends RelativeLayout { * * @param listener */ - public void setOnMapLongClickListener(@Nullable NIMap.OnMapLongClickListener listener) { + public void setOnMapLongClickListener(@Nullable OnMapLongClickListener listener) { this.mapLongClickListener = listener; } @@ -918,7 +975,21 @@ public final class NIMapView extends RelativeLayout { * * @param listener */ - public void setOnMapTouchListener(@Nullable NIMap.OnMapTouchListener listener) { + public void setOnMapTouchListener(@Nullable OnMapTouchListener listener) { this.touchListener = listener; } + + /** + * 刷新地图 + */ + public void updateMap() { + mapView.map().updateMap(); + } + + /** + * 刷新地图 + */ + public void updateMap(boolean redraw) { + mapView.map().updateMap(redraw); + } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/BaseHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/BaseHandler.kt index edfc0894..b909f5b4 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/BaseHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/BaseHandler.kt @@ -2,8 +2,21 @@ package com.navinfo.collect.library.map.handler import android.content.Context import com.navinfo.collect.library.map.NIMapView +import org.oscim.layers.Layer -open class BaseHandler(context:Context, mapView: NIMapView) { - protected val mContext:Context = context +abstract class BaseHandler(context: Context, mapView: NIMapView) { + protected val mContext: Context = context protected val mMapView: NIMapView = mapView + + fun addLayer(layer: Layer, groupType: NIMapView.LAYER_GROUPS) { + mMapView.vtmMap.layers().add( + layer, + groupType.groupIndex + ) + } + + fun removeLayer(layer: Layer) { + mMapView.vtmMap.layers().remove(layer) + } + } \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LayerManagerHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LayerManagerHandler.kt index 08d34b47..c5a4ca79 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LayerManagerHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LayerManagerHandler.kt @@ -1,35 +1,105 @@ package com.navinfo.collect.library.map.handler import android.content.Context +import android.os.Environment import com.navinfo.collect.library.map.NIMapView import com.navinfo.collect.library.map.NIMapView.LAYER_GROUPS +import com.navinfo.collect.library.map.source.NavinfoMapRastorTileSource +import okhttp3.Cache +import okhttp3.OkHttpClient import org.oscim.layers.Layer +import org.oscim.layers.LocationLayer +import org.oscim.layers.tile.bitmap.BitmapTileLayer +import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory +import java.io.File /** * Layer 操作 */ -open class LayerManagerHandler(context: Context, mapView: NIMapView) : +class LayerManagerHandler(context: Context, mapView: NIMapView) : BaseHandler(context, mapView) { + lateinit var mLocationLayer: LocationLayer + private var baseRasterLayer: Layer? = null - //增加RasterTileLayer - fun switchRasterTileLayer( - url: String?, - filePath: String? = "", - cache: Boolean? = false, - ): Boolean { - mMapView.removeBaseMap() - val layer: Layer = - mMapView.layerManager.getRasterTileLayer(mContext, url, filePath, cache!!) - if (layer != null) { - mMapView.vtmMap.layers().add(layer, LAYER_GROUPS.BASE_RASTER.groupIndex) - mMapView.vtmMap.clearMap() - return true + init { + initMap() + } + + /** + * 初始化地图 + */ + private fun initMap() { + switchBaseMapType(BASE_MAP_TYPE.CYCLE_MAP) + +// initVectorTileLayer() +// initMapLifeSource() + } + + + /** + * 切换基础底图样式 + */ + fun switchBaseMapType(type: BASE_MAP_TYPE) { + if (baseRasterLayer != null) { + mMapView.vtmMap.layers().remove(baseRasterLayer) + baseRasterLayer = null + mMapView.vtmMap.updateMap() } - return false + baseRasterLayer = getRasterTileLayer(type.url, type.tilePath, true) + addLayer(baseRasterLayer!!, LAYER_GROUPS.BASE) + mMapView.updateMap() } - //删除RasterTileLayer - fun removeRasterTileLayer(url: String) { + private fun getRasterTileLayer( + url: String?, + tilePath: String?, + useCache: Boolean + ): Layer { + val builder = OkHttpClient.Builder() + val mTileSource = + NavinfoMapRastorTileSource.builder(url).tilePath(tilePath) + .httpFactory(OkHttpFactory(builder)).build() + // 如果使用缓存 + if (useCache) { + val cacheDirectory: File = + File(Environment.getExternalStorageState() + "/" + "lalalal", "tiles-raster") + val cacheSize = 300 * 1024 * 1024 // 300 MB + val cache = Cache(cacheDirectory, cacheSize.toLong()) + builder.cache(cache) + } +// mTileSource.setHttpEngine(new OkHttpEngine.OkHttpFactory(builder)); +// mTileSource.setHttpRequestHeaders(Collections.singletonMap("User-Agent", "vtm-android-example")); +// mTileSource.setCache(new TileCache(mContext, defaultDir, url.substring(url.indexOf(":")+1))); + return BitmapTileLayer(mMapView.vtmMap, mTileSource) } +} + +/** + * 基础 + */ +enum class BASE_MAP_TYPE(// TransportMap底图 + var title: String, var url: String, var tilePath: String +) { + OPEN_STREET_MAP( + "Open Street Map", + "http://a.tile.openstreetmap.org", + "/{Z}}/{X}/{Y}.png" + ), // openStreetMap底图 + CYCLE_MAP( + "Cycle Map", + "http://c.tile.opencyclemap.org/cycle", + "/{Z}}/{X}/{Y}.png" + ), // cyclemap底图 + S_MAP( + "SMap", + "http://smap.navinfo.com/gateway/smap-raster-map/raster/basemap/tile", + "z={Z}&x={X}&y={Y}" + ), // cyclemap底图 + TRANSPORT_MAP( + "Transport Map", + "http://b.tile2.opencyclemap.org/transport", + "/{Z}}/{X}/{Y}.png" + ); + } \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt index 7259cce5..a64311d1 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt @@ -84,22 +84,10 @@ open class LineHandler(context: Context, mapView: NIMapView) : .build() mPathLayer = PathLayer(mMapView.vtmMap, lineStyle) - mMapView.layerManager.addLayer( - "defaultLineLayer", - mPathLayer, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) +// addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE) - mPathLayerTemp = if (mMapView.layerManager.containsLayer("guideLineLayer")) { - mMapView.layerManager.getLayer("guideLineLayer") as PathLayer - } else { - PathLayer(mMapView.vtmMap, newTempStyle) - } - mMapView.layerManager.addLayer( - "guideLineLayer", - mPathLayerTemp, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) + mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle) + // addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE) mPathMarkerBitmap = AndroidBitmap( BitmapFactory.decodeResource( @@ -109,21 +97,10 @@ open class LineHandler(context: Context, mapView: NIMapView) : ) val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) //新增marker图层 - mEndpointLayer = if (mMapView.layerManager.containsLayer("endpointLayer")) { - mMapView.layerManager.getLayer("endpointLayer") as ItemizedLayer - } else - //新增marker图层 - ItemizedLayer( - mMapView.vtmMap, - java.util.ArrayList(), - markerSymbol, - null - ) - mMapView.layerManager.addLayer( - "endpointLayer", - mEndpointLayer, - NIMapView.LAYER_GROUPS.VECTOR.ordinal + mEndpointLayer = ItemizedLayer( + mMapView.vtmMap, ArrayList(), markerSymbol, null ) + // addLayer(mEndpointLayer, NIMapView.LAYER_GROUPS.OPERATE) mEndpointLayer.setOnItemGestureListener(object : OnItemGestureListener { override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean { if (bDrawLine) { @@ -283,7 +260,7 @@ open class LineHandler(context: Context, mapView: NIMapView) : } fun addDrawLine(list: List) { - for(item in list){ + for (item in list) { addDrawLinePoint(item) } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt index 1274721a..7ca739be 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LocationLayerHandler.kt @@ -1,23 +1,152 @@ package com.navinfo.collect.library.map.handler import android.content.Context -import com.navinfo.collect.library.map.NILocation +import android.util.Log +import android.widget.Toast +import com.baidu.location.BDAbstractLocationListener +import com.baidu.location.BDLocation +import com.baidu.location.LocationClient +import com.baidu.location.LocationClientOption +import com.baidu.location.LocationClientOption.LocationMode import com.navinfo.collect.library.map.NIMapView +import org.oscim.layers.LocationLayer -open class LocationLayerHandler(context: Context, mapView:NIMapView) : + +class LocationLayerHandler(context: Context, mapView: NIMapView) : BaseHandler(context, mapView) { - private var mCurrentLocation: NILocation? = null + private var mCurrentLocation: BDLocation? = null + private var bFirst = true + private val mLocationLayer: LocationLayer = LocationLayer(mMapView.vtmMap) + private lateinit var locationClient: LocationClient + + init { + ///添加定位图层到地图,[NIMapView.LAYER_GROUPS.NAVIGATION] 是最上层layer组 + addLayer(mLocationLayer, NIMapView.LAYER_GROUPS.NAVIGATION) + //初始化定位 + initLocationOption() + } /** - * 设置当前位置信息 + * 初始化定位参数配置 */ - fun setCurrentLocation(location: NILocation) { - this.mCurrentLocation = location - mMapView.layerManager.locationLayer.setPosition( - location.latitude, - location.longitude, - location.radius - ) + private fun initLocationOption() { + try { + + LocationClient.setAgreePrivacy(true) + locationClient = LocationClient(mContext.applicationContext) + //定位服务的客户端。宿主程序在客户端声明此类,并调用,目前只支持在主线程中启动 + //声明LocationClient类实例并配置定位参数 + val locationOption = LocationClientOption() + val myLocationListener = MyLocationListener { + //此处的BDLocation为定位结果信息类,通过它的各种get方法可获取定位相关的全部结果 + //以下只列举部分获取经纬度相关(常用)的结果信息 + //更多结果信息获取说明,请参照类参考中BDLocation类中的说明 + + //获取纬度信息 + val latitude = it.latitude + //获取经度信息 + val longitude = it.longitude + //获取定位精度,默认值为0.0f + val radius = it.radius + //获取经纬度坐标类型,以LocationClientOption中设置过的坐标类型为准 + val coorType = it.coorType + //获取定位类型、定位错误返回码,具体信息可参照类参考中BDLocation类中的说明 + val errorCode = it.locType + mCurrentLocation = it + mLocationLayer.setPosition( + it.latitude, + it.longitude, + it.radius + ) + //第一次定位成功显示当前位置 + if (this.bFirst) { + animateToCurrentPosition() + } + + } + //注册监听函数 + locationClient.registerLocationListener(myLocationListener) + //可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 + locationOption.locationMode = LocationMode.Hight_Accuracy + //可选,默认gcj02,设置返回的定位结果坐标系,如果配合百度地图使用,建议设置为bd09ll; + locationOption.setCoorType("gcj02") + //可选,默认0,即仅定位一次,设置发起连续定位请求的间隔需要大于等于1000ms才是有效的 + locationOption.setScanSpan(1000) + //可选,设置是否需要地址信息,默认不需要 + locationOption.setIsNeedAddress(false) + //可选,设置是否需要地址描述 + locationOption.setIsNeedLocationDescribe(false) + //可选,设置是否需要设备方向结果 + locationOption.setNeedDeviceDirect(true) + //可选,默认false,设置是否当Gnss有效时按照1S1次频率输出Gnss结果 + locationOption.isLocationNotify = true + //可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死 + locationOption.setIgnoreKillProcess(true) + //可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近” + locationOption.setIsNeedLocationDescribe(false) + //可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到 + locationOption.setIsNeedLocationPoiList(false) + //可选,默认false,设置是否收集CRASH信息,默认收集 + locationOption.SetIgnoreCacheException(false) + //可选,默认false,设置是否开启卫星定位 + locationOption.isOpenGnss = true + //可选,默认false,设置定位时是否需要海拔信息,默认不需要,除基础定位版本都可用 + locationOption.setIsNeedAltitude(true) + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者,该模式下开发者无需再关心定位间隔是多少,定位SDK本身发现位置变化就会及时回调给开发者 +// locationOption.setOpenAutoNotifyMode() + //设置打开自动回调位置模式,该开关打开后,期间只要定位SDK检测到位置变化就会主动回调给开发者 + locationOption.setOpenAutoNotifyMode( + 1000, + 1, + LocationClientOption.LOC_SENSITIVITY_HIGHT + ) + //需将配置好的LocationClientOption对象,通过setLocOption方法传递给LocationClient对象使用 + locationClient.locOption = locationOption + } catch (e: Throwable) { + Toast.makeText(mContext, "定位初始化失败 $e", Toast.LENGTH_SHORT) + } + } + + /** + * 开启定位 + */ + fun startLocation() { + //开始定位 + if (!locationClient.isStarted) { + locationClient.start() + } + } + + /** + * 停止定位 + */ + fun stopLocation() { + if (locationClient.isStarted) { + locationClient.stop() + } + } + + /** + * 回到当前位置 + */ + fun animateToCurrentPosition() + { + mCurrentLocation?.run { + val mapPosition = mMapView.vtmMap.mapPosition; + mapPosition.setPosition(this.latitude, this.longitude); + mMapView.vtmMap.animator().animateTo(300, mapPosition); + } + } +} + +/** + * 实现定位回调 + */ +private class MyLocationListener(callback: (BDLocation) -> Unit) : + BDAbstractLocationListener() { + val call = callback; + override fun onReceiveLocation(location: BDLocation) { + call(location) } } \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MapBaseControlHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MapBaseControlHandler.kt deleted file mode 100644 index d8ea4113..00000000 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MapBaseControlHandler.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.navinfo.collect.library.map.handler - -import android.content.Context -import com.navinfo.collect.library.map.NIMapView - -open class MapBaseControlHandler(context: Context, mapView: NIMapView) : - BaseHandler(context, mapView) { - - /** - * 刷新地图 - */ - fun upDateMap(redraw: Boolean = true) { - if (redraw) { - mMapView.vtmMap.events.fire(org.oscim.map.Map.CLEAR_EVENT, mMapView.vtmMap.mapPosition) - } - mMapView.vtmMap.updateMap(redraw) - } -} \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt index f4e5296a..8c86e51b 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MarkHandler.kt @@ -14,56 +14,56 @@ import org.oscim.layers.marker.MarkerItem open class MarkHandler(context: Context, mapView:NIMapView) : BaseHandler(context, mapView), OnItemGestureListener { - //增加marker - fun addMarker( - geoPoint: GeoPoint, - title: String?, - description: String? = "" - ): MarkerItem { - var marker: MarkerItem? = null - for (e in mMapView.layerManager.defaultMarkerLayer.itemList) { - if (e is MarkerItem && e.title == title) { - marker = e; - break; - } - } - if (marker == null) { - var tempTitle = title; - if (tempTitle.isNullOrBlank()) { - tempTitle = StringUtil.createUUID(); - } - val marker = MarkerItem( - tempTitle, - description, - geoPoint - ) - mMapView.layerManager.defaultMarkerLayer.addItem(marker); - mMapView.vtmMap.updateMap(true) - return marker - } else { - marker.description = description - marker.geoPoint = geoPoint - mMapView.layerManager.defaultMarkerLayer.removeItem(marker) - mMapView.layerManager.defaultMarkerLayer.addItem(marker) - mMapView.vtmMap.updateMap(true) - return marker - } - } - - fun removeMarker(title: String) { - var marker: MarkerItem? = null - for (e in mMapView.layerManager.defaultMarkerLayer.itemList) { - if (e is MarkerItem && e.title == title) { - marker = e; - break; - } - } - if (marker != null) { - mMapView.layerManager.defaultMarkerLayer.removeItem(marker) - mMapView.vtmMap.updateMap(true) - } - } - +// //增加marker +// fun addMarker( +// geoPoint: GeoPoint, +// title: String?, +// description: String? = "" +// ): MarkerItem { +// var marker: MarkerItem? = null +// for (e in mMapView.layerManager.defaultMarkerLayer.itemList) { +// if (e is MarkerItem && e.title == title) { +// marker = e; +// break; +// } +// } +// if (marker == null) { +// var tempTitle = title; +// if (tempTitle.isNullOrBlank()) { +// tempTitle = StringUtil.createUUID(); +// } +// val marker = MarkerItem( +// tempTitle, +// description, +// geoPoint +// ) +// mMapView.layerManager.defaultMarkerLayer.addItem(marker); +// mMapView.vtmMap.updateMap(true) +// return marker +// } else { +// marker.description = description +// marker.geoPoint = geoPoint +// mMapView.layerManager.defaultMarkerLayer.removeItem(marker) +// mMapView.layerManager.defaultMarkerLayer.addItem(marker) +// mMapView.vtmMap.updateMap(true) +// return marker +// } +// } +// +// fun removeMarker(title: String) { +// var marker: MarkerItem? = null +// for (e in mMapView.layerManager.defaultMarkerLayer.itemList) { +// if (e is MarkerItem && e.title == title) { +// marker = e; +// break; +// } +// } +// if (marker != null) { +// mMapView.layerManager.defaultMarkerLayer.removeItem(marker) +// mMapView.vtmMap.updateMap(true) +// } +// } +// override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean { return false } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MeasureLayerHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MeasureLayerHandler.kt index c8efc207..b45c9633 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MeasureLayerHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/MeasureLayerHandler.kt @@ -7,7 +7,6 @@ import android.graphics.Color import android.text.TextPaint import android.widget.Toast import com.navinfo.collect.library.R -import com.navinfo.collect.library.map.NILayerManager import com.navinfo.collect.library.map.NIMapView import com.navinfo.collect.library.map.handler.BaseHandler import com.navinfo.collect.library.map.layers.NIPolygonLayer @@ -39,6 +38,7 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : private val bDrawPoint = false private var mAreaLayer: ItemizedLayer + //绘制线 样式 private val lineStyle: Style @@ -49,8 +49,10 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : //新增线数据引线 private var mPathLayerTemp: PathLayer + //新增线数据 private var mPathLayer: PathLayer + //线路端点图标 private var mPathMarkerBitmap: Bitmap @@ -67,7 +69,7 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : .fillColor(context.resources.getColor(R.color.draw_line_blue2_color, null)) .fillAlpha(0.5f) .strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null)) - .fillColor(context.resources.getColor(R.color.draw_line_red_color,null)) + .fillColor(context.resources.getColor(R.color.draw_line_red_color, null)) .stippleWidth(4f) .fixed(true) .build() @@ -96,22 +98,10 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : mMapView.vtmMap, lineStyle ) - mMapView.layerManager.addLayer( - "meatureLayer", - mPolygonLayer, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) +// addLayer(mPolygonLayer, NIMapView.LAYER_GROUPS.OPERATE) - mPathLayerTemp = if (mMapView.layerManager.containsLayer("meatureLineLayer")) { - mMapView.layerManager.getLayer("meatureLineLayer") as PathLayer - } else { - PathLayer(mMapView.vtmMap, newTempStyle) - } - mMapView.layerManager.addLayer( - "meatureLineLayer", - mPathLayerTemp, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) + mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle) + // addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE) mPathMarkerBitmap = AndroidBitmap( BitmapFactory.decodeResource( @@ -126,175 +116,181 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : mPathLayer = PathLayer(mMapView.vtmMap, lineStyle) - mMapView.vtmMap.layers().add(mPathLayer, NIMapView.LAYER_GROUPS.OTHER.ordinal) + addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE) } open fun drawLineOrPolygon(type: Int) { bDrawLine = true - //画面 - if (type == 3) { - if (mPolygonLayer == null) { - mPolygonLayer = NIPolygonLayer(mMapView.vtmMap, lineStyle) - mMapView.vtmMap.layers().add(mPolygonLayer, NIMapView.LAYER_GROUPS.OTHER.ordinal) - } else if (!mPolygonLayer.isEnabled) { - mPolygonLayer.isEnabled = true - } - } else { - if (mPathLayer == null) { - mPathLayer = PathLayer(mMapView.vtmMap, lineStyle) - mMapView.vtmMap.layers().add(mPathLayer, NIMapView.LAYER_GROUPS.OTHER.ordinal) - } else if (!mPathLayer.isEnabled()) { - mPathLayer.setEnabled(true) - } - } - //上一个点的引线 - if (mPathLayerTemp == null) { - mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle) - mMapView.vtmMap.layers().add(mPathLayerTemp, NIMapView.LAYER_GROUPS.OTHER.ordinal) - } else if (!mPathLayerTemp.isEnabled) { - mPathLayerTemp.isEnabled = true - } - val geoPoint: GeoPoint = - GeoPoint(mMapView.vtmMap.getMapPosition().getLatitude(), mMapView.vtmMap.getMapPosition().getLongitude()) - - //编辑点 - if (editIndex > -1) { - if (mPathMakers.size > editIndex) { - mMapView.layerManager.removeMarker(mPathMakers[editIndex], NILayerManager.MARQUEE_MARKER_LAYER) - mPathMakers.removeAt(editIndex) - if (mPathMarkerBitmap == null) { - mPathMarkerBitmap = AndroidBitmap( - BitmapFactory.decodeResource( - mContext.getResources(), - R.mipmap.icon_path_maker - ) - ) - } - val markerItem = MarkerItem(createUUID(), "", "", geoPoint) - val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) - markerItem.marker = markerSymbol - mMapView.layerManager.addMarker2MarkerLayer( - markerItem, - mPathMarkerBitmap, - NILayerManager.MARQUEE_MARKER_LAYER, - NIMapView.LAYER_GROUPS.OTHER.ordinal, - itemGestureListener - ) - mPathMakers.add(editIndex, markerItem) - if (mPathLayer != null && mPathLayer.getPoints().size > 0) { - val list: MutableList = mPathLayer.getPoints() - if (editIndex < list.size) { - list.removeAt(editIndex) - val list2: MutableList = java.util.ArrayList(list) - list2.add(editIndex, geoPoint) - mPathLayer.setPoints(list2) - } - } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) { - val list = mPolygonLayer.points - if (editIndex < list.size) { - list.removeAt(editIndex) - val list2: MutableList = java.util.ArrayList(list) - list2.add(editIndex, geoPoint) - mPolygonLayer.setPoints(list2) - } - } - if (mPathLayerTemp != null) { - mPathLayerTemp.setStyle(newTempStyle) - val list: MutableList = java.util.ArrayList() - if (type == 3 && mPathMakers.size > 1) { - list.add(mPathMakers[0].geoPoint) - list.add(geoPoint) - list.add(mPathMakers[mPathMakers.size - 1].geoPoint) - } else { - list.add(mPathMakers[mPathMakers.size - 1].geoPoint) - list.add(geoPoint) - } - mPathLayerTemp.setPoints(list) - } - } - editIndex = -1 - } else { //新增点 - if (type == 3) { - val points: MutableList = java.util.ArrayList(mPolygonLayer.points) - if (points.size > 2) { - val list: MutableList = java.util.ArrayList() - points.add(points[0]) - list.add(points[0]) - list.add(geoPoint) - list.add(mPolygonLayer.points[mPolygonLayer.points.size - 1]) - val bCross = GeometryTools.isPolygonCrosses(points, list) - if (bCross == true) { - Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show() - return - } - } - mPolygonLayer.addPoint(geoPoint) - } else { - val points: List = mPathLayer.getPoints() - if (points.size > 2) { - val list: MutableList = java.util.ArrayList() - list.add(geoPoint) - list.add(points[points.size - 1]) - val bCross = GeometryTools.isLineStringCrosses(points, list) - if (bCross == true) { - Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show() - return - } - } - mPathLayer.addPoint(geoPoint) - } - if (mPathMarkerBitmap == null) { - mPathMarkerBitmap = AndroidBitmap( - BitmapFactory.decodeResource( - mContext.getResources(), - R.mipmap.icon_path_maker - ) - ) - } - val markerItem = MarkerItem(createUUID(), "", "", geoPoint) - val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) - markerItem.marker = markerSymbol - mMapView.layerManager.addMarker2MarkerLayer( - markerItem, - mPathMarkerBitmap, - NILayerManager.MARQUEE_MARKER_LAYER, - NIMapView.LAYER_GROUPS.OTHER.ordinal, - itemGestureListener - ) - mPathMakers.add(markerItem) - } +// //画面 +// if (type == 3) { +// if (mPolygonLayer == null) { +// mPolygonLayer = NIPolygonLayer(mMapView.vtmMap, lineStyle) +// addLayer(mPolygonLayer, NIMapView.LAYER_GROUPS.OPERATE) +// } else if (!mPolygonLayer.isEnabled) { +// mPolygonLayer.isEnabled = true +// } +// } else { +// if (mPathLayer == null) { +// mPathLayer = PathLayer(mMapView.vtmMap, lineStyle) +// addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE) +// } else if (!mPathLayer.isEnabled()) { +// mPathLayer.setEnabled(true) +// } +// } +// //上一个点的引线 +// if (mPathLayerTemp == null) { +// mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle) +// addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE) +// } else if (!mPathLayerTemp.isEnabled) { +// mPathLayerTemp.isEnabled = true +// } +// val geoPoint: GeoPoint = +// GeoPoint( +// mMapView.vtmMap.getMapPosition().getLatitude(), +// mMapView.vtmMap.getMapPosition().getLongitude() +// ) +// +// //编辑点 +// if (editIndex > -1) { +// if (mPathMakers.size > editIndex) { +// mMapView.layerManager.removeMarker( +// mPathMakers[editIndex], +// NILayerManager.MARQUEE_MARKER_LAYER +// ) +// mPathMakers.removeAt(editIndex) +// if (mPathMarkerBitmap == null) { +// mPathMarkerBitmap = AndroidBitmap( +// BitmapFactory.decodeResource( +// mContext.getResources(), +// R.mipmap.icon_path_maker +// ) +// ) +// } +// val markerItem = MarkerItem(createUUID(), "", "", geoPoint) +// val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) +// markerItem.marker = markerSymbol +// mMapView.layerManager.addMarker2MarkerLayer( +// markerItem, +// mPathMarkerBitmap, +// NILayerManager.MARQUEE_MARKER_LAYER, +// NIMapView.LAYER_GROUPS.OTHER.ordinal, +// itemGestureListener +// ) +// mPathMakers.add(editIndex, markerItem) +// if (mPathLayer != null && mPathLayer.getPoints().size > 0) { +// val list: MutableList = mPathLayer.getPoints() +// if (editIndex < list.size) { +// list.removeAt(editIndex) +// val list2: MutableList = java.util.ArrayList(list) +// list2.add(editIndex, geoPoint) +// mPathLayer.setPoints(list2) +// } +// } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) { +// val list = mPolygonLayer.points +// if (editIndex < list.size) { +// list.removeAt(editIndex) +// val list2: MutableList = java.util.ArrayList(list) +// list2.add(editIndex, geoPoint) +// mPolygonLayer.setPoints(list2) +// } +// } +// if (mPathLayerTemp != null) { +// mPathLayerTemp.setStyle(newTempStyle) +// val list: MutableList = java.util.ArrayList() +// if (type == 3 && mPathMakers.size > 1) { +// list.add(mPathMakers[0].geoPoint) +// list.add(geoPoint) +// list.add(mPathMakers[mPathMakers.size - 1].geoPoint) +// } else { +// list.add(mPathMakers[mPathMakers.size - 1].geoPoint) +// list.add(geoPoint) +// } +// mPathLayerTemp.setPoints(list) +// } +// } +// editIndex = -1 +// } else { //新增点 +// if (type == 3) { +// val points: MutableList = java.util.ArrayList(mPolygonLayer.points) +// if (points.size > 2) { +// val list: MutableList = java.util.ArrayList() +// points.add(points[0]) +// list.add(points[0]) +// list.add(geoPoint) +// list.add(mPolygonLayer.points[mPolygonLayer.points.size - 1]) +// val bCross = GeometryTools.isPolygonCrosses(points, list) +// if (bCross == true) { +// Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show() +// return +// } +// } +// mPolygonLayer.addPoint(geoPoint) +// } else { +// val points: List = mPathLayer.getPoints() +// if (points.size > 2) { +// val list: MutableList = java.util.ArrayList() +// list.add(geoPoint) +// list.add(points[points.size - 1]) +// val bCross = GeometryTools.isLineStringCrosses(points, list) +// if (bCross == true) { +// Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show() +// return +// } +// } +// mPathLayer.addPoint(geoPoint) +// } +// if (mPathMarkerBitmap == null) { +// mPathMarkerBitmap = AndroidBitmap( +// BitmapFactory.decodeResource( +// mContext.getResources(), +// R.mipmap.icon_path_maker +// ) +// ) +// } +// val markerItem = MarkerItem(createUUID(), "", "", geoPoint) +// val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) +// markerItem.marker = markerSymbol +// mMapView.layerManager.addMarker2MarkerLayer( +// markerItem, +// mPathMarkerBitmap, +// NILayerManager.MARQUEE_MARKER_LAYER, +// NIMapView.LAYER_GROUPS.OTHER.ordinal, +// itemGestureListener +// ) +// mPathMakers.add(markerItem) +// } showAreaLayer() } open fun drawLineBackspace() { - if (mPathLayer != null && mPathLayer.getPoints().size > 0) { - val list: MutableList = java.util.ArrayList(mPathLayer.getPoints()) - val point = list[mPathLayer.getPoints().size - 1] - list.remove(point) - mPathLayer.setPoints(list) - mMapView.layerManager.jumpToPosition(point.longitude, point.latitude, 0) - } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) { - val list: MutableList = java.util.ArrayList(mPolygonLayer.points) - val point = list[mPolygonLayer.points.size - 1] - list.remove(point) - mPolygonLayer.setPoints(list) - mMapView.layerManager.jumpToPosition(point!!.longitude, point.latitude, 0) - } - if (mPathMakers.size > 0) { - var item: MarkerItem? = mPathMakers[mPathMakers.size - 1] - mMapView.layerManager.removeMarker(item, NILayerManager.MARQUEE_MARKER_LAYER) - mPathMakers.remove(item) - item = null - } - if (mPathMakers.size == 0 && mPathLayerTemp != null) { - mPathLayerTemp.clearPath() - } - editIndex = -1 - if (mPathLayerTemp != null) { - mPathLayerTemp.setStyle(newTempStyle) - } +// if (mPathLayer != null && mPathLayer.getPoints().size > 0) { +// val list: MutableList = java.util.ArrayList(mPathLayer.getPoints()) +// val point = list[mPathLayer.getPoints().size - 1] +// list.remove(point) +// mPathLayer.setPoints(list) +// mMapView.layerManager.jumpToPosition(point.longitude, point.latitude, 0) +// } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) { +// val list: MutableList = java.util.ArrayList(mPolygonLayer.points) +// val point = list[mPolygonLayer.points.size - 1] +// list.remove(point) +// mPolygonLayer.setPoints(list) +// mMapView.layerManager.jumpToPosition(point!!.longitude, point.latitude, 0) +// } +// if (mPathMakers.size > 0) { +// var item: MarkerItem? = mPathMakers[mPathMakers.size - 1] +// mMapView.layerManager.removeMarker(item, NILayerManager.MARQUEE_MARKER_LAYER) +// mPathMakers.remove(item) +// item = null +// } +// if (mPathMakers.size == 0 && mPathLayerTemp != null) { +// mPathLayerTemp.clearPath() +// } +// editIndex = -1 +// if (mPathLayerTemp != null) { +// mPathLayerTemp.setStyle(newTempStyle) +// } } @@ -322,8 +318,8 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : val area = DistanceUtil.planarPolygonAreaMeters2(list) var areaString: String if (area < 1000000) { - areaString = area.toString()+"平方米" - } else if (area < 10000000000.0){ + areaString = area.toString() + "平方米" + } else if (area < 10000000000.0) { val d = area / 1000000.0 val bg = BigDecimal(d) val f1 = bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble() @@ -364,25 +360,25 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : } open fun removeLine() { - bDrawLine = false - editIndex = -1 - for (item in mPathMakers) { - mMapView.layerManager.removeMarker(item, NILayerManager.MARQUEE_MARKER_LAYER) - } - mPathMakers.clear() - if (mPathLayer != null) { - mPathLayer.clearPath() - mPathLayer.isEnabled = false - } - if (mPolygonLayer != null) { - mPolygonLayer.clearPath() - mPolygonLayer.isEnabled = false - } - if (mPathLayerTemp != null) { - mPathLayerTemp.clearPath() - mPathLayerTemp.isEnabled = false - mPathLayerTemp.setStyle(newTempStyle) - } +// bDrawLine = false +// editIndex = -1 +// for (item in mPathMakers) { +// mMapView.layerManager.removeMarker(item, NILayerManager.MARQUEE_MARKER_LAYER) +// } +// mPathMakers.clear() +// if (mPathLayer != null) { +// mPathLayer.clearPath() +// mPathLayer.isEnabled = false +// } +// if (mPolygonLayer != null) { +// mPolygonLayer.clearPath() +// mPolygonLayer.isEnabled = false +// } +// if (mPathLayerTemp != null) { +// mPathLayerTemp.clearPath() +// mPathLayerTemp.isEnabled = false +// mPathLayerTemp.setStyle(newTempStyle) +// } hideAreaLayer() } @@ -399,27 +395,31 @@ open class MeasureLayerHandler(context: Context, mapView: NIMapView) : object : OnItemGestureListener { override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean { if (bDrawLine) { - for (i in mPathMakers.indices) { - val item1 = mPathMakers[i] - if (item === item1) { - mMapView.layerManager.jumpToPosition(item.getPoint().longitude, item.getPoint().latitude, 0) - editIndex = i - if (mPathLayerTemp != null) { - mPathLayerTemp.setStyle(editTempStyle) - val list: MutableList = java.util.ArrayList() - if (editIndex == 0 || editIndex == mPathMakers.size - 1) { - list.add(item.geoPoint as Nothing) - list.add(item.geoPoint as Nothing) - } else { - list.add(mPathMakers[editIndex - 1].geoPoint as Nothing) - list.add(item.geoPoint as Nothing) - list.add(mPathMakers[editIndex + 1].geoPoint as Nothing) - } - mPathLayerTemp.setPoints(list) - } - return true - } - } +// for (i in mPathMakers.indices) { +// val item1 = mPathMakers[i] +// if (item === item1) { +// mMapView.layerManager.jumpToPosition( +// item.getPoint().longitude, +// item.getPoint().latitude, +// 0 +// ) +// editIndex = i +// if (mPathLayerTemp != null) { +// mPathLayerTemp.setStyle(editTempStyle) +// val list: MutableList = java.util.ArrayList() +// if (editIndex == 0 || editIndex == mPathMakers.size - 1) { +// list.add(item.geoPoint as Nothing) +// list.add(item.geoPoint as Nothing) +// } else { +// list.add(mPathMakers[editIndex - 1].geoPoint as Nothing) +// list.add(item.geoPoint as Nothing) +// list.add(mPathMakers[editIndex + 1].geoPoint as Nothing) +// } +// mPathLayerTemp.setPoints(list) +// } +// return true +// } +// } } return false } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/PolygonHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/PolygonHandler.kt index a20d72ae..fb3b8091 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/PolygonHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/PolygonHandler.kt @@ -5,12 +5,10 @@ import android.graphics.BitmapFactory import android.util.Log import android.widget.Toast import com.navinfo.collect.library.R -import com.navinfo.collect.library.map.NILayerManager import com.navinfo.collect.library.map.NIMapView import com.navinfo.collect.library.map.layers.NIPolygonLayer import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.StringUtil -import com.navinfo.collect.library.utils.StringUtil.Companion.createUUID import org.oscim.android.canvas.AndroidBitmap import org.oscim.backend.canvas.Bitmap import org.oscim.core.GeoPoint @@ -41,13 +39,13 @@ open class PolygonHandler(context: Context, mapView: NIMapView) : private val editTempStyle: Style //新增线数据引线 - private var mPathLayerTemp: PathLayer + private lateinit var mPathLayerTemp: PathLayer //线路端点图标 private var mPathMarkerBitmap: Bitmap //线路端点marker - private val mEndpointLayer: ItemizedLayer + private lateinit var mEndpointLayer: ItemizedLayer private var bDrawPolygon = false @@ -92,22 +90,22 @@ open class PolygonHandler(context: Context, mapView: NIMapView) : mMapView.vtmMap, lineStyle ) - mMapView.layerManager.addLayer( - "defaultPolygonLayer", - mPolygonLayer, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) - - mPathLayerTemp = if (mMapView.layerManager.containsLayer("guideLineLayer")) { - mMapView.layerManager.getLayer("guideLineLayer") as PathLayer - } else { - PathLayer(mMapView.vtmMap, newTempStyle) - } - mMapView.layerManager.addLayer( - "guideLineLayer", - mPathLayerTemp, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) +// mMapView.layerManager.addLayer( +// "defaultPolygonLayer", +// mPolygonLayer, +// NIMapView.LAYER_GROUPS.VECTOR.ordinal +// ) +// +// mPathLayerTemp = if (mMapView.layerManager.containsLayer("guideLineLayer")) { +// mMapView.layerManager.getLayer("guideLineLayer") as PathLayer +// } else { +// PathLayer(mMapView.vtmMap, newTempStyle) +// } +// mMapView.layerManager.addLayer( +// "guideLineLayer", +// mPathLayerTemp, +// NIMapView.LAYER_GROUPS.VECTOR.ordinal +// ) mPathMarkerBitmap = AndroidBitmap( BitmapFactory.decodeResource( @@ -118,57 +116,57 @@ open class PolygonHandler(context: Context, mapView: NIMapView) : val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER) - mEndpointLayer = if (mMapView.layerManager.containsLayer("endpointLayer")) { - mMapView.layerManager.getLayer("endpointLayer") as ItemizedLayer - } else - //新增marker图层 - ItemizedLayer( - mMapView.vtmMap, - java.util.ArrayList(), - markerSymbol, - null - ) - mMapView.layerManager.addLayer( - "endpointLayer", - mEndpointLayer, - NIMapView.LAYER_GROUPS.VECTOR.ordinal - ) +// mEndpointLayer = if (mMapView.layerManager.containsLayer("endpointLayer")) { +// mMapView.layerManager.getLayer("endpointLayer") as ItemizedLayer +// } else +// //新增marker图层 +// ItemizedLayer( +// mMapView.vtmMap, +// java.util.ArrayList(), +// markerSymbol, +// null +// ) +// mMapView.layerManager.addLayer( +// "endpointLayer", +// mEndpointLayer, +// NIMapView.LAYER_GROUPS.VECTOR.ordinal +// ) - mEndpointLayer.setOnItemGestureListener(object : OnItemGestureListener { - override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean { - if (bDrawPolygon) { - for (i in mPathMakers.indices) { - val item1 = mPathMakers[i] - if (item === item1) { - mMapView.vtmMap.animator().animateTo( - GeoPoint( - item.getPoint().latitude, - item.getPoint().longitude - ) - ) - editIndex = i - mPathLayerTemp.setStyle(editTempStyle) - val list: MutableList = mutableListOf() - if (editIndex == 0 || editIndex == mPathMakers.size - 1) { - list.add(item.getPoint()) - list.add(item.getPoint()) - } else { - list.add(mPathMakers[editIndex - 1].geoPoint) - list.add(item.getPoint()) - list.add(mPathMakers[editIndex + 1].geoPoint) - } - mPathLayerTemp.setPoints(list) - return false - } - } - } - return false - } - - override fun onItemLongPress(index: Int, item: MarkerInterface): Boolean { - return false - } - }) +// mEndpointLayer.setOnItemGestureListener(object : OnItemGestureListener { +// override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean { +// if (bDrawPolygon) { +// for (i in mPathMakers.indices) { +// val item1 = mPathMakers[i] +// if (item === item1) { +// mMapView.vtmMap.animator().animateTo( +// GeoPoint( +// item.getPoint().latitude, +// item.getPoint().longitude +// ) +// ) +// editIndex = i +// mPathLayerTemp.setStyle(editTempStyle) +// val list: MutableList = mutableListOf() +// if (editIndex == 0 || editIndex == mPathMakers.size - 1) { +// list.add(item.getPoint()) +// list.add(item.getPoint()) +// } else { +// list.add(mPathMakers[editIndex - 1].geoPoint) +// list.add(item.getPoint()) +// list.add(mPathMakers[editIndex + 1].geoPoint) +// } +// mPathLayerTemp.setPoints(list) +// return false +// } +// } +// } +// return false +// } +// +// override fun onItemLongPress(index: Int, item: MarkerInterface): Boolean { +// return false +// } +// }) } fun addDrawPolygonPoint(geoPoint: GeoPoint): List { diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviLocationLayer.java b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviLocationLayer.java index ce3f5bc0..7baaccf6 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviLocationLayer.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviLocationLayer.java @@ -61,7 +61,7 @@ public class NaviLocationLayer extends LocationTextureLayer { this.locationRenderer.setColor(0xffa1dbf5); this.locationRenderer.setShowAccuracyZoom(4); this.setEnabled(true); // 默认开启当前位置显示 - mMap.layers().add(this, NIMapView.LAYER_GROUPS.ALLWAYS_SHOW_GROUP.getGroupIndex()); + mMap.layers().add(this, NIMapView.LAYER_GROUPS.NAVIGATION.getGroupIndex()); return this; } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviMapScaleBar.java b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviMapScaleBar.java index 11577e02..93b563d9 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviMapScaleBar.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/NaviMapScaleBar.java @@ -73,7 +73,7 @@ public class NaviMapScaleBar extends MapScaleBar { BitmapRenderer renderer = mapScaleBarLayer.getRenderer(); renderer.setPosition(position); // 设置scaleBar在地图上的位置 renderer.setOffset(xOffset * CanvasAdapter.getScale(), yOffset* CanvasAdapter.getScale()); - this.map.layers().add(mapScaleBarLayer, NIMapView.LAYER_GROUPS.ALLWAYS_SHOW_GROUP.ordinal()); + this.map.layers().add(mapScaleBarLayer, NIMapView.LAYER_GROUPS.NAVIGATION.ordinal()); return mapScaleBarLayer; } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/source/NavinfoMapRastorTileSource.java b/collect-library/src/main/java/com/navinfo/collect/library/map/source/NavinfoMapRastorTileSource.java index 8f39f217..36fb57ea 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/source/NavinfoMapRastorTileSource.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/source/NavinfoMapRastorTileSource.java @@ -1,5 +1,7 @@ package com.navinfo.collect.library.map.source; +import android.util.Log; + import org.oscim.backend.CanvasAdapter; import org.oscim.backend.canvas.Bitmap; import org.oscim.core.Tile; @@ -32,6 +34,7 @@ public class NavinfoMapRastorTileSource extends UrlTileSource { public static class Builder> extends UrlTileSource.Builder { private boolean isTMSProtocol = true; + public Builder(String url) { super(url, DEFAULT_PATH); overZoom(2); diff --git a/collect-library/src/main/res/layout/base_map_layout.xml b/collect-library/src/main/res/layout/base_map_layout.xml index 5f42858a..26ddc2eb 100644 --- a/collect-library/src/main/res/layout/base_map_layout.xml +++ b/collect-library/src/main/res/layout/base_map_layout.xml @@ -1,64 +1,70 @@ + android:layout_width="match_parent" + android:layout_height="match_parent"> + + android:layout_height="match_parent" /> + + android:padding="@dimen/nimap_defalut_padding" + android:src="@mipmap/compass" /> + android:padding="@dimen/nimap_defalut_padding" + android:src="@mipmap/logo" /> + android:layout_alignParentBottom="true" + android:orientation="vertical" + android:padding="@dimen/nimap_defalut_padding"> + + android:src="@drawable/icon_map_zoom_in" /> + + android:layout_height="@dimen/nimap_defalut_padding" /> + + android:src="@drawable/icon_map_zoom_out" /> + android:orientation="vertical" + android:visibility="gone"> + + + \ No newline at end of file