updated marker image & testing some features

pull/391/head
Jackson Rosenthal 2022-02-17 17:43:06 -05:00
rodzic 068f2ba8b2
commit dcad0f3ad9
3 zmienionych plików z 24 dodań i 8 usunięć

Wyświetl plik

@ -77,6 +77,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
private lateinit var binding: MapViewBinding
private lateinit var mapNotAllowedBinding: MapNotAllowedBinding
private lateinit var viewAnnotationManager: ViewAnnotationManager
private lateinit var mapStyleURI: String
private lateinit var point: Geometry
@ -86,6 +87,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
private val nodeLayerId = "node-layer"
private val labelLayerId = "label-layer"
private val markerImageId = "my-marker-image"
private val userPointImageId = "user-image";
private var stylePackCancelable: Cancelable? = null
private var tilePackCancelable: Cancelable? = null
@ -105,7 +107,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
.iconAllowOverlap(true)
private val userTouchLayer = SymbolLayer(userTouchLayerId, userTouchPositionId)
.iconImage(markerImageId)
.iconImage(userPointImageId)
.iconAnchor(IconAnchor.BOTTOM)
.iconAllowOverlap(true)
@ -241,7 +243,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
// Remove the style pack with the style url.
// 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.
offlineManager.removeStylePack(Style.OUTDOORS)
offlineManager.removeStylePack(mapStyleURI)
MapboxMap.clearData(resourceOptions) {
it.error?.let { error ->
@ -262,7 +264,6 @@ class MapFragment : ScreenFragment("Map"), Logging {
binding.fabStyleToggle.setOnClickListener {
//TODO: Setup Style menu for satellite view, street view, & outdoor view
// downloadOfflineRegion()
}
binding.downloadRegion.setOnClickListener {
downloadOfflineRegion()
@ -290,6 +291,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
it.addImage(markerImageId, markerIcon)
it.addLayer(nodeLayer)
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
// the data eviction algorithm and are not considered when calculating the disk cache size.
stylePackCancelable = offlineManager.loadStylePack(
Style.OUTDOORS,
mapStyleURI,
// Build Style pack load options
StylePackLoadOptions.Builder()
.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 OfflineManager is responsible for creating tileset descriptors for the given style and zoom range.
val tilesetDescriptor = offlineManager.createTilesetDescriptor(
TilesetDescriptorOptions.Builder()
.styleURI(Style.OUTDOORS)
.styleURI(mapStyleURI)
.minZoom(0)
.maxZoom(16)
.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.
tilePackCancelable = tileStore.loadTileRegion(
TILE_REGION_ID,
TILE_REGION_ID, // Make this dynamic
TileRegionLoadOptions.Builder()
.geometry(point)
.descriptors(listOf(tilesetDescriptor))
@ -441,10 +445,14 @@ class MapFragment : ScreenFragment("Map"), Logging {
/**
* 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 {
val userDefinedPointImg =
ContextCompat.getDrawable(requireActivity(), R.drawable.ic_twotone_person_24)!!
ContextCompat.getDrawable(
requireActivity(),
R.drawable.baseline_location_on_white_24dp
)!!
.toBitmap()
point = Point.fromLngLat(it.longitude(), it.latitude())
@ -452,7 +460,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
userTouchPosition.geometry(point)
if (!style.styleLayerExists(userTouchLayerId)) {
style.addImage("userImage", userDefinedPointImg)
style.addImage(userPointImageId, userDefinedPointImg)
style.addSource(userTouchPosition)
style.addLayer(userTouchLayer)
}
@ -479,6 +487,7 @@ class MapFragment : ScreenFragment("Map"), Logging {
binding.stylePackDownloadProgress.progress = progress.toInt()
}
// TODO: Make this dynamic
private val click = OnMapClickListener {
if (binding.fabStyleToggle.isVisible && binding.downloadRegion.isVisible) {
binding.fabStyleToggle.visibility = View.INVISIBLE

Wyświetl plik

@ -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>

Wyświetl plik

@ -125,4 +125,5 @@
<string name="delete_all_messages">Delete All Messages</string>
<string name="modem_config_slow_long">Long Range / Slow</string>
<string name="style_selection">Style Selection</string>
<string name="download_region">Download Region</string>
</resources>