kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Fixed issue with adding multiple layers instead of moving touch position
rodzic
955d1de0c8
commit
ffe66ec81c
|
@ -53,6 +53,9 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
private val userTouchLayerId = "user-touch-layer"
|
private val userTouchLayerId = "user-touch-layer"
|
||||||
private var nodePositions = GeoJsonSource(GeoJsonSource.Builder(nodeSourceId))
|
private var nodePositions = GeoJsonSource(GeoJsonSource.Builder(nodeSourceId))
|
||||||
|
|
||||||
|
private val userTouchPosition = GeoJsonSource(GeoJsonSource.Builder(userTouchPositionId))
|
||||||
|
|
||||||
|
|
||||||
private val nodeLayer = SymbolLayer(nodeLayerId, nodeSourceId)
|
private val nodeLayer = SymbolLayer(nodeLayerId, nodeSourceId)
|
||||||
.iconImage(markerImageId)
|
.iconImage(markerImageId)
|
||||||
.iconAnchor(IconAnchor.BOTTOM)
|
.iconAnchor(IconAnchor.BOTTOM)
|
||||||
|
@ -208,19 +211,23 @@ class MapFragment : ScreenFragment("Map"), Logging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Create list of touch positions that can be updated on new press
|
/**
|
||||||
|
* OnLongClick of the map set a position marker.
|
||||||
|
*/
|
||||||
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.ic_twotone_person_24)!!
|
||||||
.toBitmap()
|
.toBitmap()
|
||||||
val point = Point.fromLngLat(it.longitude(), it.latitude())
|
val point = Point.fromLngLat(it.longitude(), it.latitude())
|
||||||
val userTouchPosition = GeoJsonSource(GeoJsonSource.Builder(userTouchPositionId))
|
|
||||||
userTouchPosition.geometry(point)
|
|
||||||
|
|
||||||
mapView?.getMapboxMap()?.getStyle()?.let { style ->
|
mapView?.getMapboxMap()?.getStyle()?.let { style ->
|
||||||
style.addImage("userImage", userDefinedPointImg)
|
userTouchPosition.geometry(point)
|
||||||
style.addSource(userTouchPosition)
|
|
||||||
style.addLayer(userTouchLayer)
|
if (!style.styleLayerExists(userTouchLayerId)) {
|
||||||
|
style.addImage("userImage", userDefinedPointImg)
|
||||||
|
style.addSource(userTouchPosition)
|
||||||
|
style.addLayer(userTouchLayer)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return@OnMapLongClickListener true
|
return@OnMapLongClickListener true
|
||||||
|
|
Ładowanie…
Reference in New Issue