diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + @@ -15,6 +16,13 @@ + + + + + @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt index 57bb3aa..a8eab8e 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -22,4 +22,17 @@ const val ACCOUNT = "account" const val PASSWORD = "password" const val USER_DETAIL_MODEL = "userDetailModel" + + val LAYER = arrayListOf( + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/0", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/1", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/2", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/3", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/4", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/5", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/6", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/7", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/8", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/9" + ) } \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt index 57bb3aa..a8eab8e 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -22,4 +22,17 @@ const val ACCOUNT = "account" const val PASSWORD = "password" const val USER_DETAIL_MODEL = "userDetailModel" + + val LAYER = arrayListOf( + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/0", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/1", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/2", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/3", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/4", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/5", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/6", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/7", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/8", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/9" + ) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt new file mode 100644 index 0000000..976da4a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt @@ -0,0 +1,275 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.arcgisservices.LevelOfDetail +import com.esri.arcgisruntime.arcgisservices.TileInfo +import com.esri.arcgisruntime.geometry.Envelope +import com.esri.arcgisruntime.geometry.Point +import com.esri.arcgisruntime.geometry.SpatialReference +import com.esri.arcgisruntime.layers.WebTiledLayer +import java.util.* + + +object TianDiTuMethods { + private val SubDomain: List = listOf("t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7") + private const val URL_VECTOR_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=vec_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=img_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=ter_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cta_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + const val URL_VECTOR_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=vec_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=img_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=ter_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cta_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + private const val DPI = 96 + private const val minZoomLevel = 1 + private const val maxZoomLevel = 18 + private const val tileWidth = 256 + private const val tileHeight = 256 + private const val LAYER_NAME_VECTOR = "vec" + private const val LAYER_NAME_VECTOR_ANNOTATION_CHINESE = "cva" + private const val LAYER_NAME_VECTOR_ANNOTATION_ENGLISH = "eva" + private const val LAYER_NAME_IMAGE = "img" + private const val LAYER_NAME_IMAGE_ANNOTATION_CHINESE = "cia" + private const val LAYER_NAME_IMAGE_ANNOTATION_ENGLISH = "eia" + private const val LAYER_NAME_TERRAIN = "ter" + private const val LAYER_NAME_TERRAIN_ANNOTATION_CHINESE = "cta" + + val SRID_2000 = SpatialReference.create(4490) + private val SRID_MERCATOR = SpatialReference.create(102100) + private const val X_MIN_2000 = -180.0 + private const val Y_MIN_2000 = -90.0 + private const val X_MAX_2000 = 180.0 + private const val Y_MAX_2000 = 90.0 + + private const val X_MIN_MERCATOR = -20037508.3427892 + private const val Y_MIN_MERCATOR = -20037508.3427892 + private const val X_MAX_MERCATOR = 20037508.3427892 + private const val Y_MAX_MERCATOR = 20037508.3427892 + private val ORIGIN_2000: Point = Point(-180.0, 90.0, SRID_2000) + private val ORIGIN_MERCATOR: Point = Point(-20037508.3427892, 20037508.3427892, SRID_MERCATOR) + private val ENVELOPE_2000: Envelope = + Envelope(X_MIN_2000, Y_MIN_2000, X_MAX_2000, Y_MAX_2000, SRID_2000) + private val ENVELOPE_MERCATOR: Envelope = + Envelope(X_MIN_MERCATOR, Y_MIN_MERCATOR, X_MAX_MERCATOR, Y_MAX_MERCATOR, SRID_MERCATOR) + + private val SCALES = doubleArrayOf( + 2.958293554545656E8, 1.479146777272828E8, + 7.39573388636414E7, 3.69786694318207E7, + 1.848933471591035E7, 9244667.357955175, + 4622333.678977588, 2311166.839488794, + 1155583.419744397, 577791.7098721985, + 288895.85493609926, 144447.92746804963, + 72223.96373402482, 36111.98186701241, + 18055.990933506204, 9027.995466753102, + 4513.997733376551, 2256.998866688275, + 1128.4994333441375 + ) + private val RESOLUTIONS_MERCATOR = doubleArrayOf( + 78271.51696402048, 39135.75848201024, + 19567.87924100512, 9783.93962050256, + 4891.96981025128, 2445.98490512564, + 1222.99245256282, 611.49622628141, + 305.748113140705, 152.8740565703525, + 76.43702828517625, 38.21851414258813, + 19.109257071294063, 9.554628535647032, + 4.777314267823516, 2.388657133911758, + 1.194328566955879, 0.5971642834779395, + 0.298582141738970 + ) + + private val RESOLUTIONS_2000 = doubleArrayOf( + 0.7031249999891485, 0.35156249999999994, + 0.17578124999999997, 0.08789062500000014, + 0.04394531250000007, 0.021972656250000007, + 0.01098632812500002, 0.00549316406250001, + 0.0027465820312500017, 0.0013732910156250009, + 0.000686645507812499, 0.0003433227539062495, + 0.00017166137695312503, 0.00008583068847656251, + 0.000042915344238281406, 0.000021457672119140645, + 0.000010728836059570307, 0.000005364418029785169 + ) + + fun createTianDiTuTiledLayer(layerType: String?): WebTiledLayer? { + return createTianDiTuTiledLayer(getTianDiTuLayerType(layerType)) + } + + fun createTianDiTuTiledLayer(layerType: LayerType?): WebTiledLayer? { + var webTiledLayer: WebTiledLayer? = null + var mainUrl = "" + var mainName = "" + val mainTileInfo: TileInfo? + val mainEnvelope: Envelope? + var mainIs2000 = false + try { + when (layerType) { + LayerType.TIANDITU_VECTOR_2000 -> { + mainUrl = URL_VECTOR_2000 + mainName = LAYER_NAME_VECTOR + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_MERCATOR -> { + mainUrl = URL_VECTOR_MERCATOR + mainName = LAYER_NAME_VECTOR + } + LayerType.TIANDITU_IMAGE_2000 -> { + mainUrl = URL_IMAGE_2000 + mainName = LAYER_NAME_IMAGE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_IMAGE_MERCATOR -> { + mainUrl = URL_IMAGE_MERCATOR + mainName = LAYER_NAME_IMAGE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_TERRAIN_2000 -> { + mainUrl = URL_TERRAIN_2000 + mainName = LAYER_NAME_TERRAIN + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_MERCATOR -> { + mainUrl = URL_TERRAIN_MERCATOR + mainName = LAYER_NAME_TERRAIN + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + } + } + val mainLevelOfDetail: MutableList = ArrayList() + val mainOrigin: Point? + if (mainIs2000) { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_2000[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_2000 + mainOrigin = ORIGIN_2000 + } else { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_MERCATOR[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_MERCATOR + mainOrigin = ORIGIN_MERCATOR + } + mainTileInfo = TileInfo( + DPI, + TileInfo.ImageFormat.PNG24, + mainLevelOfDetail, + mainOrigin, + mainOrigin.spatialReference, + tileHeight, + tileWidth + ) + webTiledLayer = WebTiledLayer( + mainUrl, + SubDomain, + mainTileInfo, + mainEnvelope + ) + webTiledLayer.name = mainName + webTiledLayer.loadAsync() + } catch (e: Exception) { + e.cause + } + return webTiledLayer + } + + private fun getTianDiTuLayerType(layerType: String?): LayerType { + var result = LayerType.TIANDITU_VECTOR_2000 + when (layerType) { + "TIANDITU_VECTOR_MERCATOR" -> result = LayerType.TIANDITU_VECTOR_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_IMAGE_MERCATOR" -> result = LayerType.TIANDITU_IMAGE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_TERRAIN_MERCATOR" -> result = LayerType.TIANDITU_TERRAIN_MERCATOR + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_2000" -> result = LayerType.TIANDITU_VECTOR_2000 + "TIANDITU_VECTOR_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 + "TIANDITU_IMAGE_2000" -> result = LayerType.TIANDITU_IMAGE_2000 + "TIANDITU_IMAGE_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 + "TIANDITU_TERRAIN_2000" -> result = LayerType.TIANDITU_TERRAIN_2000 + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 + } + return result + } +} \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt index 57bb3aa..a8eab8e 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -22,4 +22,17 @@ const val ACCOUNT = "account" const val PASSWORD = "password" const val USER_DETAIL_MODEL = "userDetailModel" + + val LAYER = arrayListOf( + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/0", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/1", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/2", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/3", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/4", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/5", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/6", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/7", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/8", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/9" + ) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt new file mode 100644 index 0000000..976da4a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt @@ -0,0 +1,275 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.arcgisservices.LevelOfDetail +import com.esri.arcgisruntime.arcgisservices.TileInfo +import com.esri.arcgisruntime.geometry.Envelope +import com.esri.arcgisruntime.geometry.Point +import com.esri.arcgisruntime.geometry.SpatialReference +import com.esri.arcgisruntime.layers.WebTiledLayer +import java.util.* + + +object TianDiTuMethods { + private val SubDomain: List = listOf("t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7") + private const val URL_VECTOR_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=vec_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=img_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=ter_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cta_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + const val URL_VECTOR_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=vec_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=img_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=ter_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cta_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + private const val DPI = 96 + private const val minZoomLevel = 1 + private const val maxZoomLevel = 18 + private const val tileWidth = 256 + private const val tileHeight = 256 + private const val LAYER_NAME_VECTOR = "vec" + private const val LAYER_NAME_VECTOR_ANNOTATION_CHINESE = "cva" + private const val LAYER_NAME_VECTOR_ANNOTATION_ENGLISH = "eva" + private const val LAYER_NAME_IMAGE = "img" + private const val LAYER_NAME_IMAGE_ANNOTATION_CHINESE = "cia" + private const val LAYER_NAME_IMAGE_ANNOTATION_ENGLISH = "eia" + private const val LAYER_NAME_TERRAIN = "ter" + private const val LAYER_NAME_TERRAIN_ANNOTATION_CHINESE = "cta" + + val SRID_2000 = SpatialReference.create(4490) + private val SRID_MERCATOR = SpatialReference.create(102100) + private const val X_MIN_2000 = -180.0 + private const val Y_MIN_2000 = -90.0 + private const val X_MAX_2000 = 180.0 + private const val Y_MAX_2000 = 90.0 + + private const val X_MIN_MERCATOR = -20037508.3427892 + private const val Y_MIN_MERCATOR = -20037508.3427892 + private const val X_MAX_MERCATOR = 20037508.3427892 + private const val Y_MAX_MERCATOR = 20037508.3427892 + private val ORIGIN_2000: Point = Point(-180.0, 90.0, SRID_2000) + private val ORIGIN_MERCATOR: Point = Point(-20037508.3427892, 20037508.3427892, SRID_MERCATOR) + private val ENVELOPE_2000: Envelope = + Envelope(X_MIN_2000, Y_MIN_2000, X_MAX_2000, Y_MAX_2000, SRID_2000) + private val ENVELOPE_MERCATOR: Envelope = + Envelope(X_MIN_MERCATOR, Y_MIN_MERCATOR, X_MAX_MERCATOR, Y_MAX_MERCATOR, SRID_MERCATOR) + + private val SCALES = doubleArrayOf( + 2.958293554545656E8, 1.479146777272828E8, + 7.39573388636414E7, 3.69786694318207E7, + 1.848933471591035E7, 9244667.357955175, + 4622333.678977588, 2311166.839488794, + 1155583.419744397, 577791.7098721985, + 288895.85493609926, 144447.92746804963, + 72223.96373402482, 36111.98186701241, + 18055.990933506204, 9027.995466753102, + 4513.997733376551, 2256.998866688275, + 1128.4994333441375 + ) + private val RESOLUTIONS_MERCATOR = doubleArrayOf( + 78271.51696402048, 39135.75848201024, + 19567.87924100512, 9783.93962050256, + 4891.96981025128, 2445.98490512564, + 1222.99245256282, 611.49622628141, + 305.748113140705, 152.8740565703525, + 76.43702828517625, 38.21851414258813, + 19.109257071294063, 9.554628535647032, + 4.777314267823516, 2.388657133911758, + 1.194328566955879, 0.5971642834779395, + 0.298582141738970 + ) + + private val RESOLUTIONS_2000 = doubleArrayOf( + 0.7031249999891485, 0.35156249999999994, + 0.17578124999999997, 0.08789062500000014, + 0.04394531250000007, 0.021972656250000007, + 0.01098632812500002, 0.00549316406250001, + 0.0027465820312500017, 0.0013732910156250009, + 0.000686645507812499, 0.0003433227539062495, + 0.00017166137695312503, 0.00008583068847656251, + 0.000042915344238281406, 0.000021457672119140645, + 0.000010728836059570307, 0.000005364418029785169 + ) + + fun createTianDiTuTiledLayer(layerType: String?): WebTiledLayer? { + return createTianDiTuTiledLayer(getTianDiTuLayerType(layerType)) + } + + fun createTianDiTuTiledLayer(layerType: LayerType?): WebTiledLayer? { + var webTiledLayer: WebTiledLayer? = null + var mainUrl = "" + var mainName = "" + val mainTileInfo: TileInfo? + val mainEnvelope: Envelope? + var mainIs2000 = false + try { + when (layerType) { + LayerType.TIANDITU_VECTOR_2000 -> { + mainUrl = URL_VECTOR_2000 + mainName = LAYER_NAME_VECTOR + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_MERCATOR -> { + mainUrl = URL_VECTOR_MERCATOR + mainName = LAYER_NAME_VECTOR + } + LayerType.TIANDITU_IMAGE_2000 -> { + mainUrl = URL_IMAGE_2000 + mainName = LAYER_NAME_IMAGE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_IMAGE_MERCATOR -> { + mainUrl = URL_IMAGE_MERCATOR + mainName = LAYER_NAME_IMAGE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_TERRAIN_2000 -> { + mainUrl = URL_TERRAIN_2000 + mainName = LAYER_NAME_TERRAIN + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_MERCATOR -> { + mainUrl = URL_TERRAIN_MERCATOR + mainName = LAYER_NAME_TERRAIN + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + } + } + val mainLevelOfDetail: MutableList = ArrayList() + val mainOrigin: Point? + if (mainIs2000) { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_2000[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_2000 + mainOrigin = ORIGIN_2000 + } else { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_MERCATOR[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_MERCATOR + mainOrigin = ORIGIN_MERCATOR + } + mainTileInfo = TileInfo( + DPI, + TileInfo.ImageFormat.PNG24, + mainLevelOfDetail, + mainOrigin, + mainOrigin.spatialReference, + tileHeight, + tileWidth + ) + webTiledLayer = WebTiledLayer( + mainUrl, + SubDomain, + mainTileInfo, + mainEnvelope + ) + webTiledLayer.name = mainName + webTiledLayer.loadAsync() + } catch (e: Exception) { + e.cause + } + return webTiledLayer + } + + private fun getTianDiTuLayerType(layerType: String?): LayerType { + var result = LayerType.TIANDITU_VECTOR_2000 + when (layerType) { + "TIANDITU_VECTOR_MERCATOR" -> result = LayerType.TIANDITU_VECTOR_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_IMAGE_MERCATOR" -> result = LayerType.TIANDITU_IMAGE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_TERRAIN_MERCATOR" -> result = LayerType.TIANDITU_TERRAIN_MERCATOR + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_2000" -> result = LayerType.TIANDITU_VECTOR_2000 + "TIANDITU_VECTOR_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 + "TIANDITU_IMAGE_2000" -> result = LayerType.TIANDITU_IMAGE_2000 + "TIANDITU_IMAGE_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 + "TIANDITU_TERRAIN_2000" -> result = LayerType.TIANDITU_TERRAIN_2000 + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 + } + return result + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml index 19789c1..e44f70d 100644 --- a/app/src/main/res/layout/fragment_monitor.xml +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -31,7 +31,7 @@ android:textSize="@dimen/sp_14" /> - diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt index 57bb3aa..a8eab8e 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -22,4 +22,17 @@ const val ACCOUNT = "account" const val PASSWORD = "password" const val USER_DETAIL_MODEL = "userDetailModel" + + val LAYER = arrayListOf( + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/0", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/1", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/2", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/3", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/4", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/5", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/6", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/7", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/8", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/9" + ) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt new file mode 100644 index 0000000..976da4a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt @@ -0,0 +1,275 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.arcgisservices.LevelOfDetail +import com.esri.arcgisruntime.arcgisservices.TileInfo +import com.esri.arcgisruntime.geometry.Envelope +import com.esri.arcgisruntime.geometry.Point +import com.esri.arcgisruntime.geometry.SpatialReference +import com.esri.arcgisruntime.layers.WebTiledLayer +import java.util.* + + +object TianDiTuMethods { + private val SubDomain: List = listOf("t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7") + private const val URL_VECTOR_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=vec_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=img_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=ter_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cta_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + const val URL_VECTOR_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=vec_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=img_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=ter_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cta_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + private const val DPI = 96 + private const val minZoomLevel = 1 + private const val maxZoomLevel = 18 + private const val tileWidth = 256 + private const val tileHeight = 256 + private const val LAYER_NAME_VECTOR = "vec" + private const val LAYER_NAME_VECTOR_ANNOTATION_CHINESE = "cva" + private const val LAYER_NAME_VECTOR_ANNOTATION_ENGLISH = "eva" + private const val LAYER_NAME_IMAGE = "img" + private const val LAYER_NAME_IMAGE_ANNOTATION_CHINESE = "cia" + private const val LAYER_NAME_IMAGE_ANNOTATION_ENGLISH = "eia" + private const val LAYER_NAME_TERRAIN = "ter" + private const val LAYER_NAME_TERRAIN_ANNOTATION_CHINESE = "cta" + + val SRID_2000 = SpatialReference.create(4490) + private val SRID_MERCATOR = SpatialReference.create(102100) + private const val X_MIN_2000 = -180.0 + private const val Y_MIN_2000 = -90.0 + private const val X_MAX_2000 = 180.0 + private const val Y_MAX_2000 = 90.0 + + private const val X_MIN_MERCATOR = -20037508.3427892 + private const val Y_MIN_MERCATOR = -20037508.3427892 + private const val X_MAX_MERCATOR = 20037508.3427892 + private const val Y_MAX_MERCATOR = 20037508.3427892 + private val ORIGIN_2000: Point = Point(-180.0, 90.0, SRID_2000) + private val ORIGIN_MERCATOR: Point = Point(-20037508.3427892, 20037508.3427892, SRID_MERCATOR) + private val ENVELOPE_2000: Envelope = + Envelope(X_MIN_2000, Y_MIN_2000, X_MAX_2000, Y_MAX_2000, SRID_2000) + private val ENVELOPE_MERCATOR: Envelope = + Envelope(X_MIN_MERCATOR, Y_MIN_MERCATOR, X_MAX_MERCATOR, Y_MAX_MERCATOR, SRID_MERCATOR) + + private val SCALES = doubleArrayOf( + 2.958293554545656E8, 1.479146777272828E8, + 7.39573388636414E7, 3.69786694318207E7, + 1.848933471591035E7, 9244667.357955175, + 4622333.678977588, 2311166.839488794, + 1155583.419744397, 577791.7098721985, + 288895.85493609926, 144447.92746804963, + 72223.96373402482, 36111.98186701241, + 18055.990933506204, 9027.995466753102, + 4513.997733376551, 2256.998866688275, + 1128.4994333441375 + ) + private val RESOLUTIONS_MERCATOR = doubleArrayOf( + 78271.51696402048, 39135.75848201024, + 19567.87924100512, 9783.93962050256, + 4891.96981025128, 2445.98490512564, + 1222.99245256282, 611.49622628141, + 305.748113140705, 152.8740565703525, + 76.43702828517625, 38.21851414258813, + 19.109257071294063, 9.554628535647032, + 4.777314267823516, 2.388657133911758, + 1.194328566955879, 0.5971642834779395, + 0.298582141738970 + ) + + private val RESOLUTIONS_2000 = doubleArrayOf( + 0.7031249999891485, 0.35156249999999994, + 0.17578124999999997, 0.08789062500000014, + 0.04394531250000007, 0.021972656250000007, + 0.01098632812500002, 0.00549316406250001, + 0.0027465820312500017, 0.0013732910156250009, + 0.000686645507812499, 0.0003433227539062495, + 0.00017166137695312503, 0.00008583068847656251, + 0.000042915344238281406, 0.000021457672119140645, + 0.000010728836059570307, 0.000005364418029785169 + ) + + fun createTianDiTuTiledLayer(layerType: String?): WebTiledLayer? { + return createTianDiTuTiledLayer(getTianDiTuLayerType(layerType)) + } + + fun createTianDiTuTiledLayer(layerType: LayerType?): WebTiledLayer? { + var webTiledLayer: WebTiledLayer? = null + var mainUrl = "" + var mainName = "" + val mainTileInfo: TileInfo? + val mainEnvelope: Envelope? + var mainIs2000 = false + try { + when (layerType) { + LayerType.TIANDITU_VECTOR_2000 -> { + mainUrl = URL_VECTOR_2000 + mainName = LAYER_NAME_VECTOR + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_MERCATOR -> { + mainUrl = URL_VECTOR_MERCATOR + mainName = LAYER_NAME_VECTOR + } + LayerType.TIANDITU_IMAGE_2000 -> { + mainUrl = URL_IMAGE_2000 + mainName = LAYER_NAME_IMAGE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_IMAGE_MERCATOR -> { + mainUrl = URL_IMAGE_MERCATOR + mainName = LAYER_NAME_IMAGE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_TERRAIN_2000 -> { + mainUrl = URL_TERRAIN_2000 + mainName = LAYER_NAME_TERRAIN + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_MERCATOR -> { + mainUrl = URL_TERRAIN_MERCATOR + mainName = LAYER_NAME_TERRAIN + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + } + } + val mainLevelOfDetail: MutableList = ArrayList() + val mainOrigin: Point? + if (mainIs2000) { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_2000[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_2000 + mainOrigin = ORIGIN_2000 + } else { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_MERCATOR[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_MERCATOR + mainOrigin = ORIGIN_MERCATOR + } + mainTileInfo = TileInfo( + DPI, + TileInfo.ImageFormat.PNG24, + mainLevelOfDetail, + mainOrigin, + mainOrigin.spatialReference, + tileHeight, + tileWidth + ) + webTiledLayer = WebTiledLayer( + mainUrl, + SubDomain, + mainTileInfo, + mainEnvelope + ) + webTiledLayer.name = mainName + webTiledLayer.loadAsync() + } catch (e: Exception) { + e.cause + } + return webTiledLayer + } + + private fun getTianDiTuLayerType(layerType: String?): LayerType { + var result = LayerType.TIANDITU_VECTOR_2000 + when (layerType) { + "TIANDITU_VECTOR_MERCATOR" -> result = LayerType.TIANDITU_VECTOR_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_IMAGE_MERCATOR" -> result = LayerType.TIANDITU_IMAGE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_TERRAIN_MERCATOR" -> result = LayerType.TIANDITU_TERRAIN_MERCATOR + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_2000" -> result = LayerType.TIANDITU_VECTOR_2000 + "TIANDITU_VECTOR_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 + "TIANDITU_IMAGE_2000" -> result = LayerType.TIANDITU_IMAGE_2000 + "TIANDITU_IMAGE_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 + "TIANDITU_TERRAIN_2000" -> result = LayerType.TIANDITU_TERRAIN_2000 + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 + } + return result + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml index 19789c1..e44f70d 100644 --- a/app/src/main/res/layout/fragment_monitor.xml +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -31,7 +31,7 @@ android:textSize="@dimen/sp_14" /> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50482d9..045c479 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,6 @@ SmartTown 中国航天科工集团 + runtimelite,1000,rud4449636536,none,NKMFA0PL4S0DRJE15166 + AAPK93b60c1b1b064409aafaa03bc5bd3df1eM4wAH7Cxp9rfcD_AEmUqjuk3p2nq-P_tAiHCRh-iyuLIBqeDiKD0urjkJd42iCh \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e33cce1..86ec1a2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,10 @@ targetCompatibility JavaVersion.VERSION_1_8 } + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + } + kotlin { experimental { coroutines 'enable' @@ -91,6 +95,8 @@ implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.1.0' //高德地图 implementation 'com.amap.api:3dmap:latest.integration' + //ArcGIS + implementation 'com.esri.arcgisruntime:arcgis-android:100.14.0' //推送SDK implementation 'com.getui:gtsdk:3.2.10.0' //个推SDK implementation 'com.getui:gtc:3.1.9.0' //个推核心组件 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1fe841c..c582d6c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -15,6 +16,13 @@ + + + + + = ArrayList() + private var allMarkerOptions: MutableList = ArrayList() - /** - * 视野内的marker - */ - private var markerOptionsInView: MutableList = ArrayList() + private lateinit var graphics: ListenableList + private lateinit var graphicsOverlays: ListenableList override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { monitorView = inflater.inflate(R.layout.fragment_monitor, container, false) //地图初始化 - initMap(savedInstanceState) + initMap() monitorView.rightOperateView.setOnClickListener { requireContext().navigatePageTo() @@ -77,96 +82,75 @@ longitudeList.add(longitude) //将所有设备信息转化缓存为Marker点 allMarkerOptions.add( - MarkerOptions() - .position(LatLng(latitude, longitude)) - .title(video.name) - .snippet(video.code) + Point(longitude, latitude, TianDiTuMethods.SRID_2000) ) } - - //计算所有点的中心点位置 - val centerLatLng = LatLng(latitudeList.average(), longitudeList.average()) - //移动到指定经纬度 - val cameraPosition = CameraPosition(centerLatLng, 16f, 0f, 0f) - val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition) - aMap.animateCamera(cameraUpdate, 2000, null) } } + allMarkerOptions.forEach { p -> + val pinDrawable = BitmapDrawable( + resources, BitmapFactory.decodeResource( + resources, R.mipmap.map_pin + ) + ) + val pictureMarker = PictureMarkerSymbol(pinDrawable) + pictureMarker.height = 24f + pictureMarker.width = 24f + pictureMarker.loadAsync() //异步加载Marker,防止阻塞 + + + val graphicsOverlay = GraphicsOverlay() + graphics = graphicsOverlay.graphics + graphics.add(Graphic(p, pictureMarker)) + graphicsOverlays.add(graphicsOverlay) + } } }) return monitorView } - private fun initMap(savedInstanceState: Bundle?) { - monitorView.mapView.onCreate(savedInstanceState) - aMap = monitorView.mapView.map - aMap.mapType = AMap.MAP_TYPE_NORMAL - val uiSettings = aMap.uiSettings - uiSettings.isCompassEnabled = true - uiSettings.zoomPosition = AMapOptions.ZOOM_POSITION_RIGHT_CENTER - uiSettings.isTiltGesturesEnabled = false//不许地图随手势倾斜角度 + private fun initMap() { + //创建底图、并设置底图图层 + val baseMapLayer = TianDiTuMethods.createTianDiTuTiledLayer(LayerType.TIANDITU_IMAGE_2000) + val baseLayerMap = Basemap(baseMapLayer) + val chineseAnnotationLayer = TianDiTuMethods.createTianDiTuTiledLayer( + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + ) + baseLayerMap.baseLayers.add(chineseAnnotationLayer) - // 地图加载成功监听 - aMap.addOnMapLoadedListener(this) - // 地图缩放监听 - aMap.addOnCameraChangeListener(this) - // marker 点击事件监听 -// aMap.addOnMarkerClickListener(this) - // 点击marker弹出自定义popup -// aMap.setInfoWindowAdapter(this) - //信息窗点击事件 -// aMap.addOnInfoWindowClickListener(this) - } - - override fun onMapLoaded() { - //地图加载成功之后显示聚合点数据 - initClustersMarkers() - } - - override fun onCameraChange(p0: CameraPosition?) { - - } - - override fun onCameraChangeFinish(p0: CameraPosition?) { - initClustersMarkers() - } - - private fun initClustersMarkers() { - val proj = aMap.projection - val dm = resources.displayMetrics - var screenLocation: Point - markerOptionsInView.clear() - // 获取在当前视野内的marker - allMarkerOptions.forEach { - screenLocation = proj.toScreenLocation(it.position) - if (screenLocation.x >= 0 && screenLocation.y >= 0 && screenLocation.x <= dm.widthPixels && screenLocation.y <= dm.heightPixels) { - it.icon(BitmapDescriptorFactory.fromBitmap(BitmapDescriptorFactory.fromResource(R.mipmap.map_pin).bitmap)) - markerOptionsInView.add(it) - } + val arcGISMap = ArcGISMap(baseLayerMap) + //添加自定义arcgis图层 + val layers = ArrayList() + LocaleConstant.LAYER.forEach { + layers.add(ArcGISHelper.createFeatureLayer(it)) } - markerOptionsInView.forEach { - aMap.addMarker(it) - } + arcGISMap.operationalLayers.addAll(layers) + monitorView.mapView.map = arcGISMap + monitorView.mapView.isAttributionTextVisible = false //去掉左下角属性标识 + monitorView.mapView.setViewpoint(Viewpoint(22.29334127, 113.4937572, 6400.0)) + + //Marker相关Layer + graphicsOverlays = monitorView.mapView.graphicsOverlays + } + + private fun clearPictureMarker() { + graphics.clear() + graphicsOverlays.clear() } /***以下是地图生命周期管理************************************************************************/ override fun onResume() { super.onResume() - monitorView.mapView.onResume() + monitorView.mapView.resume() } override fun onPause() { super.onPause() - monitorView.mapView.onPause() - } - - override fun onSaveInstanceState(outState: Bundle) { - super.onSaveInstanceState(outState) - monitorView.mapView.onSaveInstanceState(outState) + monitorView.mapView.pause() } override fun onDestroy() { super.onDestroy() - monitorView.mapView.onDestroy() + monitorView.mapView.dispose() } } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt new file mode 100644 index 0000000..2688240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/ArcGISHelper.kt @@ -0,0 +1,13 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.data.ServiceFeatureTable +import com.esri.arcgisruntime.layers.FeatureLayer + +object ArcGISHelper { + fun createFeatureLayer(url: String): FeatureLayer { + val serviceFeatureTable = ServiceFeatureTable(url) + serviceFeatureTable.featureRequestMode = + ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE + return FeatureLayer(serviceFeatureTable) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt new file mode 100644 index 0000000..75e92ea --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LayerType.kt @@ -0,0 +1,83 @@ +package com.casic.smart.town.sanxi.util + +enum class LayerType { + /** + * 天地图矢量墨卡托投影地图服务 + */ + TIANDITU_VECTOR_MERCATOR, + + /** + * 天地图矢量墨卡托中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量墨卡托英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图影像墨卡托投影地图服务 + */ + TIANDITU_IMAGE_MERCATOR, + + /** + * 天地图影像墨卡托投影中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图影像墨卡托投影英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR, + + /** + * 天地图地形墨卡托投影地图服务 + */ + TIANDITU_TERRAIN_MERCATOR, + + /** + * 天地图地形墨卡托投影中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR, + + /** + * 天地图矢量国家2000坐标系地图服务 + */ + TIANDITU_VECTOR_2000, + + /** + * 天地图矢量国家2000坐标系中文标注 + */ + TIANDITU_VECTOR_ANNOTATION_CHINESE_2000, + + /** + * 天地图矢量国家2000坐标系英文标注 + */ + TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000, + + /** + * 天地图影像国家2000坐标系地图服务 + */ + TIANDITU_IMAGE_2000, + + /** + * 天地图影像国家2000坐标系中文标注 + */ + TIANDITU_IMAGE_ANNOTATION_CHINESE_2000, + + /** + * 天地图影像国家2000坐标系英文标注 + */ + TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000, + + /** + * 天地图地形国家2000坐标系地图服务 + */ + TIANDITU_TERRAIN_2000, + + /** + * 天地图地形国家2000坐标系中文标注 + */ + TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt index 57bb3aa..a8eab8e 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/LocaleConstant.kt @@ -22,4 +22,17 @@ const val ACCOUNT = "account" const val PASSWORD = "password" const val USER_DETAIL_MODEL = "userDetailModel" + + val LAYER = arrayListOf( + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/0", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/1", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/2", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/3", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/4", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/5", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/6", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/7", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/8", + "http://111.198.10.15:13002/arcgis/rest/services/sxxz/MapServer/9" + ) } \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt new file mode 100644 index 0000000..976da4a --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/util/TianDiTuMethods.kt @@ -0,0 +1,275 @@ +package com.casic.smart.town.sanxi.util + +import com.esri.arcgisruntime.arcgisservices.LevelOfDetail +import com.esri.arcgisruntime.arcgisservices.TileInfo +import com.esri.arcgisruntime.geometry.Envelope +import com.esri.arcgisruntime.geometry.Point +import com.esri.arcgisruntime.geometry.SpatialReference +import com.esri.arcgisruntime.layers.WebTiledLayer +import java.util.* + + +object TianDiTuMethods { + private val SubDomain: List = listOf("t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7") + private const val URL_VECTOR_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=vec_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eva_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=img_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=eia_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=ter_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_2000 = + "http://{subDomain}.tianditu.com/DataServer?T=cta_c&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + const val URL_VECTOR_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=vec_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eva_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=img_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=eia_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=ter_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + private const val URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR = + "http://{subDomain}.tianditu.com/DataServer?T=cta_w&x={col}&y={row}&l={level}&tk=13a5450a2738de2b764542ae3d9929d9" + + private const val DPI = 96 + private const val minZoomLevel = 1 + private const val maxZoomLevel = 18 + private const val tileWidth = 256 + private const val tileHeight = 256 + private const val LAYER_NAME_VECTOR = "vec" + private const val LAYER_NAME_VECTOR_ANNOTATION_CHINESE = "cva" + private const val LAYER_NAME_VECTOR_ANNOTATION_ENGLISH = "eva" + private const val LAYER_NAME_IMAGE = "img" + private const val LAYER_NAME_IMAGE_ANNOTATION_CHINESE = "cia" + private const val LAYER_NAME_IMAGE_ANNOTATION_ENGLISH = "eia" + private const val LAYER_NAME_TERRAIN = "ter" + private const val LAYER_NAME_TERRAIN_ANNOTATION_CHINESE = "cta" + + val SRID_2000 = SpatialReference.create(4490) + private val SRID_MERCATOR = SpatialReference.create(102100) + private const val X_MIN_2000 = -180.0 + private const val Y_MIN_2000 = -90.0 + private const val X_MAX_2000 = 180.0 + private const val Y_MAX_2000 = 90.0 + + private const val X_MIN_MERCATOR = -20037508.3427892 + private const val Y_MIN_MERCATOR = -20037508.3427892 + private const val X_MAX_MERCATOR = 20037508.3427892 + private const val Y_MAX_MERCATOR = 20037508.3427892 + private val ORIGIN_2000: Point = Point(-180.0, 90.0, SRID_2000) + private val ORIGIN_MERCATOR: Point = Point(-20037508.3427892, 20037508.3427892, SRID_MERCATOR) + private val ENVELOPE_2000: Envelope = + Envelope(X_MIN_2000, Y_MIN_2000, X_MAX_2000, Y_MAX_2000, SRID_2000) + private val ENVELOPE_MERCATOR: Envelope = + Envelope(X_MIN_MERCATOR, Y_MIN_MERCATOR, X_MAX_MERCATOR, Y_MAX_MERCATOR, SRID_MERCATOR) + + private val SCALES = doubleArrayOf( + 2.958293554545656E8, 1.479146777272828E8, + 7.39573388636414E7, 3.69786694318207E7, + 1.848933471591035E7, 9244667.357955175, + 4622333.678977588, 2311166.839488794, + 1155583.419744397, 577791.7098721985, + 288895.85493609926, 144447.92746804963, + 72223.96373402482, 36111.98186701241, + 18055.990933506204, 9027.995466753102, + 4513.997733376551, 2256.998866688275, + 1128.4994333441375 + ) + private val RESOLUTIONS_MERCATOR = doubleArrayOf( + 78271.51696402048, 39135.75848201024, + 19567.87924100512, 9783.93962050256, + 4891.96981025128, 2445.98490512564, + 1222.99245256282, 611.49622628141, + 305.748113140705, 152.8740565703525, + 76.43702828517625, 38.21851414258813, + 19.109257071294063, 9.554628535647032, + 4.777314267823516, 2.388657133911758, + 1.194328566955879, 0.5971642834779395, + 0.298582141738970 + ) + + private val RESOLUTIONS_2000 = doubleArrayOf( + 0.7031249999891485, 0.35156249999999994, + 0.17578124999999997, 0.08789062500000014, + 0.04394531250000007, 0.021972656250000007, + 0.01098632812500002, 0.00549316406250001, + 0.0027465820312500017, 0.0013732910156250009, + 0.000686645507812499, 0.0003433227539062495, + 0.00017166137695312503, 0.00008583068847656251, + 0.000042915344238281406, 0.000021457672119140645, + 0.000010728836059570307, 0.000005364418029785169 + ) + + fun createTianDiTuTiledLayer(layerType: String?): WebTiledLayer? { + return createTianDiTuTiledLayer(getTianDiTuLayerType(layerType)) + } + + fun createTianDiTuTiledLayer(layerType: LayerType?): WebTiledLayer? { + var webTiledLayer: WebTiledLayer? = null + var mainUrl = "" + var mainName = "" + val mainTileInfo: TileInfo? + val mainEnvelope: Envelope? + var mainIs2000 = false + try { + when (layerType) { + LayerType.TIANDITU_VECTOR_2000 -> { + mainUrl = URL_VECTOR_2000 + mainName = LAYER_NAME_VECTOR + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_MERCATOR -> { + mainUrl = URL_VECTOR_MERCATOR + mainName = LAYER_NAME_VECTOR + } + LayerType.TIANDITU_IMAGE_2000 -> { + mainUrl = URL_IMAGE_2000 + mainName = LAYER_NAME_IMAGE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_CHINESE + } + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_IMAGE_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_IMAGE_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_IMAGE_MERCATOR -> { + mainUrl = URL_IMAGE_MERCATOR + mainName = LAYER_NAME_IMAGE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_2000 + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + mainIs2000 = true + } + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_CHINESE + } + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR -> { + mainUrl = URL_VECTOR_ANNOTATION_ENGLISH_MERCATOR + mainName = LAYER_NAME_VECTOR_ANNOTATION_ENGLISH + } + LayerType.TIANDITU_TERRAIN_2000 -> { + mainUrl = URL_TERRAIN_2000 + mainName = LAYER_NAME_TERRAIN + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_2000 + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + mainIs2000 = true + } + LayerType.TIANDITU_TERRAIN_MERCATOR -> { + mainUrl = URL_TERRAIN_MERCATOR + mainName = LAYER_NAME_TERRAIN + } + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR -> { + mainUrl = URL_TERRAIN_ANNOTATION_CHINESE_MERCATOR + mainName = LAYER_NAME_TERRAIN_ANNOTATION_CHINESE + } + } + val mainLevelOfDetail: MutableList = ArrayList() + val mainOrigin: Point? + if (mainIs2000) { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_2000[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_2000 + mainOrigin = ORIGIN_2000 + } else { + for (i in minZoomLevel..maxZoomLevel) { + val item = LevelOfDetail(i, RESOLUTIONS_MERCATOR[i - 1], SCALES[i - 1]) + mainLevelOfDetail.add(item) + } + mainEnvelope = ENVELOPE_MERCATOR + mainOrigin = ORIGIN_MERCATOR + } + mainTileInfo = TileInfo( + DPI, + TileInfo.ImageFormat.PNG24, + mainLevelOfDetail, + mainOrigin, + mainOrigin.spatialReference, + tileHeight, + tileWidth + ) + webTiledLayer = WebTiledLayer( + mainUrl, + SubDomain, + mainTileInfo, + mainEnvelope + ) + webTiledLayer.name = mainName + webTiledLayer.loadAsync() + } catch (e: Exception) { + e.cause + } + return webTiledLayer + } + + private fun getTianDiTuLayerType(layerType: String?): LayerType { + var result = LayerType.TIANDITU_VECTOR_2000 + when (layerType) { + "TIANDITU_VECTOR_MERCATOR" -> result = LayerType.TIANDITU_VECTOR_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_IMAGE_MERCATOR" -> result = LayerType.TIANDITU_IMAGE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_MERCATOR + "TIANDITU_TERRAIN_MERCATOR" -> result = LayerType.TIANDITU_TERRAIN_MERCATOR + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_MERCATOR + "TIANDITU_VECTOR_2000" -> result = LayerType.TIANDITU_VECTOR_2000 + "TIANDITU_VECTOR_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_CHINESE_2000 + "TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_VECTOR_ANNOTATION_ENGLISH_2000 + "TIANDITU_IMAGE_2000" -> result = LayerType.TIANDITU_IMAGE_2000 + "TIANDITU_IMAGE_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_CHINESE_2000 + "TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000" -> result = + LayerType.TIANDITU_IMAGE_ANNOTATION_ENGLISH_2000 + "TIANDITU_TERRAIN_2000" -> result = LayerType.TIANDITU_TERRAIN_2000 + "TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000" -> result = + LayerType.TIANDITU_TERRAIN_ANNOTATION_CHINESE_2000 + } + return result + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_monitor.xml b/app/src/main/res/layout/fragment_monitor.xml index 19789c1..e44f70d 100644 --- a/app/src/main/res/layout/fragment_monitor.xml +++ b/app/src/main/res/layout/fragment_monitor.xml @@ -31,7 +31,7 @@ android:textSize="@dimen/sp_14" /> - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50482d9..045c479 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,6 @@ SmartTown 中国航天科工集团 + runtimelite,1000,rud4449636536,none,NKMFA0PL4S0DRJE15166 + AAPK93b60c1b1b064409aafaa03bc5bd3df1eM4wAH7Cxp9rfcD_AEmUqjuk3p2nq-P_tAiHCRh-iyuLIBqeDiKD0urjkJd42iCh \ No newline at end of file diff --git a/build.gradle b/build.gradle index 62b9d90..459e81b 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,10 @@ maven { url 'https://jitpack.io' } google() maven { url "https://mvn.getui.com/nexus/content/repositories/releases/"} + //ArcGIS + maven { + url 'https://esri.jfrog.io/artifactory/arcgis' + } } }