diff --git a/app/src/main/assets/TestLatLng.json b/app/src/main/assets/TestLatLng.json new file mode 100644 index 0000000..ffe7b2f --- /dev/null +++ b/app/src/main/assets/TestLatLng.json @@ -0,0 +1,48 @@ +{ + "data": [ + { + "longitude": 113.501308, + "latitude": 22.29167891 + }, + { + "longitude": 113.4965794, + "latitude": 22.28993659 + }, + { + "longitude": 113.4981261, + "latitude": 22.29154654 + }, + { + "longitude": 113.5008387, + "latitude": 22.29186628 + }, + { + "longitude": 113.5001809, + "latitude": 22.29046962 + }, + { + "longitude": 113.4997276, + "latitude": 22.2927874 + }, + { + "longitude": 113.4989203, + "latitude": 22.29117224 + }, + { + "longitude": 113.5009471, + "latitude": 22.28869176 + }, + { + "longitude": 113.4994695, + "latitude": 22.29241627 + }, + { + "longitude": 113.5019316, + "latitude": 22.28810393 + }, + { + "longitude": 113.5033705, + "latitude": 22.28694087 + } + ] +} \ No newline at end of file diff --git a/app/src/main/assets/TestLatLng.json b/app/src/main/assets/TestLatLng.json new file mode 100644 index 0000000..ffe7b2f --- /dev/null +++ b/app/src/main/assets/TestLatLng.json @@ -0,0 +1,48 @@ +{ + "data": [ + { + "longitude": 113.501308, + "latitude": 22.29167891 + }, + { + "longitude": 113.4965794, + "latitude": 22.28993659 + }, + { + "longitude": 113.4981261, + "latitude": 22.29154654 + }, + { + "longitude": 113.5008387, + "latitude": 22.29186628 + }, + { + "longitude": 113.5001809, + "latitude": 22.29046962 + }, + { + "longitude": 113.4997276, + "latitude": 22.2927874 + }, + { + "longitude": 113.4989203, + "latitude": 22.29117224 + }, + { + "longitude": 113.5009471, + "latitude": 22.28869176 + }, + { + "longitude": 113.4994695, + "latitude": 22.29241627 + }, + { + "longitude": 113.5019316, + "latitude": 22.28810393 + }, + { + "longitude": 113.5033705, + "latitude": 22.28694087 + } + ] +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt index c360cb7..c90f2e6 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider -import com.amap.api.maps.CoordinateConverter +import com.amap.api.location.CoordinateConverter import com.casic.smart.town.sanxi.R import com.casic.smart.town.sanxi.model.VideoModel import com.casic.smart.town.sanxi.util.ArcGISHelper @@ -32,7 +32,7 @@ class MonitorPageFragment : Fragment() { - private val kTag = "HomePageFragment" + private val kTag = "MonitorPageFragment" private lateinit var monitorView: View private lateinit var videoViewModel: VideoViewModel @@ -87,11 +87,10 @@ } } } + allMarkerOptions.forEach { p -> val pinDrawable = BitmapDrawable( - resources, BitmapFactory.decodeResource( - resources, R.mipmap.map_pin - ) + resources, BitmapFactory.decodeResource(resources, R.mipmap.map_pin) ) val pictureMarker = PictureMarkerSymbol(pinDrawable) pictureMarker.height = 24f @@ -106,6 +105,38 @@ } } }) + +// val data = requireContext().readAssetsFile("TestLatLng.json") +// val testData = Gson().fromJson( +// data, object : TypeToken() {}.type +// ) +// +// testData.data.forEach { video -> +// val lat = video.latitude.toString() +// val lng = video.longitude.toString() +// val latitude = lat.toDouble() +// val longitude = lng.toDouble() +// //将所有设备信息转化缓存为Marker点 +// allMarkerOptions.add( +// Point(longitude, latitude, TianDiTuMethods.SRID_2000) +// ) +// } +// +// 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 } diff --git a/app/src/main/assets/TestLatLng.json b/app/src/main/assets/TestLatLng.json new file mode 100644 index 0000000..ffe7b2f --- /dev/null +++ b/app/src/main/assets/TestLatLng.json @@ -0,0 +1,48 @@ +{ + "data": [ + { + "longitude": 113.501308, + "latitude": 22.29167891 + }, + { + "longitude": 113.4965794, + "latitude": 22.28993659 + }, + { + "longitude": 113.4981261, + "latitude": 22.29154654 + }, + { + "longitude": 113.5008387, + "latitude": 22.29186628 + }, + { + "longitude": 113.5001809, + "latitude": 22.29046962 + }, + { + "longitude": 113.4997276, + "latitude": 22.2927874 + }, + { + "longitude": 113.4989203, + "latitude": 22.29117224 + }, + { + "longitude": 113.5009471, + "latitude": 22.28869176 + }, + { + "longitude": 113.4994695, + "latitude": 22.29241627 + }, + { + "longitude": 113.5019316, + "latitude": 22.28810393 + }, + { + "longitude": 113.5033705, + "latitude": 22.28694087 + } + ] +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt index c360cb7..c90f2e6 100644 --- a/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt +++ b/app/src/main/java/com/casic/smart/town/sanxi/fragment/MonitorPageFragment.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider -import com.amap.api.maps.CoordinateConverter +import com.amap.api.location.CoordinateConverter import com.casic.smart.town.sanxi.R import com.casic.smart.town.sanxi.model.VideoModel import com.casic.smart.town.sanxi.util.ArcGISHelper @@ -32,7 +32,7 @@ class MonitorPageFragment : Fragment() { - private val kTag = "HomePageFragment" + private val kTag = "MonitorPageFragment" private lateinit var monitorView: View private lateinit var videoViewModel: VideoViewModel @@ -87,11 +87,10 @@ } } } + allMarkerOptions.forEach { p -> val pinDrawable = BitmapDrawable( - resources, BitmapFactory.decodeResource( - resources, R.mipmap.map_pin - ) + resources, BitmapFactory.decodeResource(resources, R.mipmap.map_pin) ) val pictureMarker = PictureMarkerSymbol(pinDrawable) pictureMarker.height = 24f @@ -106,6 +105,38 @@ } } }) + +// val data = requireContext().readAssetsFile("TestLatLng.json") +// val testData = Gson().fromJson( +// data, object : TypeToken() {}.type +// ) +// +// testData.data.forEach { video -> +// val lat = video.latitude.toString() +// val lng = video.longitude.toString() +// val latitude = lat.toDouble() +// val longitude = lng.toDouble() +// //将所有设备信息转化缓存为Marker点 +// allMarkerOptions.add( +// Point(longitude, latitude, TianDiTuMethods.SRID_2000) +// ) +// } +// +// 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 } diff --git a/app/src/main/java/com/casic/smart/town/sanxi/model/TestLatLngModel.java b/app/src/main/java/com/casic/smart/town/sanxi/model/TestLatLngModel.java new file mode 100644 index 0000000..add7240 --- /dev/null +++ b/app/src/main/java/com/casic/smart/town/sanxi/model/TestLatLngModel.java @@ -0,0 +1,37 @@ +package com.casic.smart.town.sanxi.model; + +import java.util.List; + +public class TestLatLngModel { + + private List data; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public static class DataModel { + private double longitude; + private double latitude; + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + } +}