kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
updated marker image & testing some features
rodzic
068f2ba8b2
commit
dcad0f3ad9
|
@ -77,6 +77,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
private lateinit var binding: MapViewBinding
|
private lateinit var binding: MapViewBinding
|
||||||
private lateinit var mapNotAllowedBinding: MapNotAllowedBinding
|
private lateinit var mapNotAllowedBinding: MapNotAllowedBinding
|
||||||
private lateinit var viewAnnotationManager: ViewAnnotationManager
|
private lateinit var viewAnnotationManager: ViewAnnotationManager
|
||||||
|
private lateinit var mapStyleURI: String
|
||||||
|
|
||||||
private lateinit var point: Geometry
|
private lateinit var point: Geometry
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
private val nodeLayerId = "node-layer"
|
private val nodeLayerId = "node-layer"
|
||||||
private val labelLayerId = "label-layer"
|
private val labelLayerId = "label-layer"
|
||||||
private val markerImageId = "my-marker-image"
|
private val markerImageId = "my-marker-image"
|
||||||
|
private val userPointImageId = "user-image";
|
||||||
|
|
||||||
private var stylePackCancelable: Cancelable? = null
|
private var stylePackCancelable: Cancelable? = null
|
||||||
private var tilePackCancelable: Cancelable? = null
|
private var tilePackCancelable: Cancelable? = null
|
||||||
|
@ -105,7 +107,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
.iconAllowOverlap(true)
|
.iconAllowOverlap(true)
|
||||||
|
|
||||||
private val userTouchLayer = SymbolLayer(userTouchLayerId, userTouchPositionId)
|
private val userTouchLayer = SymbolLayer(userTouchLayerId, userTouchPositionId)
|
||||||
.iconImage(markerImageId)
|
.iconImage(userPointImageId)
|
||||||
.iconAnchor(IconAnchor.BOTTOM)
|
.iconAnchor(IconAnchor.BOTTOM)
|
||||||
.iconAllowOverlap(true)
|
.iconAllowOverlap(true)
|
||||||
|
|
||||||
|
@ -241,7 +243,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
// Remove the style pack with the style url.
|
// Remove the style pack with the style url.
|
||||||
// Note this will not remove the downloaded style pack, instead, it will just mark the resources
|
// Note this will not remove the downloaded style pack, instead, it will just mark the resources
|
||||||
// not a part of the existing style pack. The resources still exists as disk cache.
|
// not a part of the existing style pack. The resources still exists as disk cache.
|
||||||
offlineManager.removeStylePack(Style.OUTDOORS)
|
offlineManager.removeStylePack(mapStyleURI)
|
||||||
|
|
||||||
MapboxMap.clearData(resourceOptions) {
|
MapboxMap.clearData(resourceOptions) {
|
||||||
it.error?.let { error ->
|
it.error?.let { error ->
|
||||||
|
@ -262,7 +264,6 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
binding.fabStyleToggle.setOnClickListener {
|
binding.fabStyleToggle.setOnClickListener {
|
||||||
|
|
||||||
//TODO: Setup Style menu for satellite view, street view, & outdoor view
|
//TODO: Setup Style menu for satellite view, street view, & outdoor view
|
||||||
// downloadOfflineRegion()
|
|
||||||
}
|
}
|
||||||
binding.downloadRegion.setOnClickListener {
|
binding.downloadRegion.setOnClickListener {
|
||||||
downloadOfflineRegion()
|
downloadOfflineRegion()
|
||||||
|
@ -290,6 +291,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
it.addImage(markerImageId, markerIcon)
|
it.addImage(markerImageId, markerIcon)
|
||||||
it.addLayer(nodeLayer)
|
it.addLayer(nodeLayer)
|
||||||
it.addLayer(labelLayer)
|
it.addLayer(labelLayer)
|
||||||
|
this.mapStyleURI = map.getStyle()?.styleURI.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +330,9 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
|
|
||||||
// Style packs are stored in the disk cache database, but their resources are not subject to
|
// Style packs are stored in the disk cache database, but their resources are not subject to
|
||||||
// the data eviction algorithm and are not considered when calculating the disk cache size.
|
// the data eviction algorithm and are not considered when calculating the disk cache size.
|
||||||
|
|
||||||
stylePackCancelable = offlineManager.loadStylePack(
|
stylePackCancelable = offlineManager.loadStylePack(
|
||||||
Style.OUTDOORS,
|
mapStyleURI,
|
||||||
// Build Style pack load options
|
// Build Style pack load options
|
||||||
StylePackLoadOptions.Builder()
|
StylePackLoadOptions.Builder()
|
||||||
.glyphsRasterizationMode(GlyphsRasterizationMode.IDEOGRAPHS_RASTERIZED_LOCALLY)
|
.glyphsRasterizationMode(GlyphsRasterizationMode.IDEOGRAPHS_RASTERIZED_LOCALLY)
|
||||||
|
@ -380,9 +383,10 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
// the region area geometry to load a new Tile Region.
|
// the region area geometry to load a new Tile Region.
|
||||||
|
|
||||||
// The OfflineManager is responsible for creating tileset descriptors for the given style and zoom range.
|
// The OfflineManager is responsible for creating tileset descriptors for the given style and zoom range.
|
||||||
|
|
||||||
val tilesetDescriptor = offlineManager.createTilesetDescriptor(
|
val tilesetDescriptor = offlineManager.createTilesetDescriptor(
|
||||||
TilesetDescriptorOptions.Builder()
|
TilesetDescriptorOptions.Builder()
|
||||||
.styleURI(Style.OUTDOORS)
|
.styleURI(mapStyleURI)
|
||||||
.minZoom(0)
|
.minZoom(0)
|
||||||
.maxZoom(16)
|
.maxZoom(16)
|
||||||
.build()
|
.build()
|
||||||
|
@ -393,7 +397,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
|
|
||||||
// Note that the TileStore path must be the same with the TileStore used when initialise the MapView.
|
// Note that the TileStore path must be the same with the TileStore used when initialise the MapView.
|
||||||
tilePackCancelable = tileStore.loadTileRegion(
|
tilePackCancelable = tileStore.loadTileRegion(
|
||||||
TILE_REGION_ID,
|
TILE_REGION_ID, // Make this dynamic
|
||||||
TileRegionLoadOptions.Builder()
|
TileRegionLoadOptions.Builder()
|
||||||
.geometry(point)
|
.geometry(point)
|
||||||
.descriptors(listOf(tilesetDescriptor))
|
.descriptors(listOf(tilesetDescriptor))
|
||||||
|
@ -441,10 +445,14 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OnLongClick of the map set a position marker.
|
* OnLongClick of the map set a position marker.
|
||||||
|
* If a user long-clicks again, the position of the first marker will be updated
|
||||||
*/
|
*/
|
||||||
private val longClick = OnMapLongClickListener {
|
private val longClick = OnMapLongClickListener {
|
||||||
val userDefinedPointImg =
|
val userDefinedPointImg =
|
||||||
ContextCompat.getDrawable(requireActivity(), R.drawable.ic_twotone_person_24)!!
|
ContextCompat.getDrawable(
|
||||||
|
requireActivity(),
|
||||||
|
R.drawable.baseline_location_on_white_24dp
|
||||||
|
)!!
|
||||||
.toBitmap()
|
.toBitmap()
|
||||||
point = Point.fromLngLat(it.longitude(), it.latitude())
|
point = Point.fromLngLat(it.longitude(), it.latitude())
|
||||||
|
|
||||||
|
@ -452,7 +460,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
userTouchPosition.geometry(point)
|
userTouchPosition.geometry(point)
|
||||||
|
|
||||||
if (!style.styleLayerExists(userTouchLayerId)) {
|
if (!style.styleLayerExists(userTouchLayerId)) {
|
||||||
style.addImage("userImage", userDefinedPointImg)
|
style.addImage(userPointImageId, userDefinedPointImg)
|
||||||
style.addSource(userTouchPosition)
|
style.addSource(userTouchPosition)
|
||||||
style.addLayer(userTouchLayer)
|
style.addLayer(userTouchLayer)
|
||||||
}
|
}
|
||||||
|
@ -479,6 +487,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
binding.stylePackDownloadProgress.progress = progress.toInt()
|
binding.stylePackDownloadProgress.progress = progress.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make this dynamic
|
||||||
private val click = OnMapClickListener {
|
private val click = OnMapClickListener {
|
||||||
if (binding.fabStyleToggle.isVisible && binding.downloadRegion.isVisible) {
|
if (binding.fabStyleToggle.isVisible && binding.downloadRegion.isVisible) {
|
||||||
binding.fabStyleToggle.visibility = View.INVISIBLE
|
binding.fabStyleToggle.visibility = View.INVISIBLE
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#FFFFFF" android:viewportHeight="24.0" android:viewportWidth="24.0" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
|
||||||
|
|
||||||
|
</vector>
|
|
@ -125,4 +125,5 @@
|
||||||
<string name="delete_all_messages">Delete All Messages</string>
|
<string name="delete_all_messages">Delete All Messages</string>
|
||||||
<string name="modem_config_slow_long">Long Range / Slow</string>
|
<string name="modem_config_slow_long">Long Range / Slow</string>
|
||||||
<string name="style_selection">Style Selection</string>
|
<string name="style_selection">Style Selection</string>
|
||||||
|
<string name="download_region">Download Region</string>
|
||||||
</resources>
|
</resources>
|
Ładowanie…
Reference in New Issue