mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
display points of interest with names
This commit is contained in:
parent
abe0144d48
commit
d33bbfc04f
3 changed files with 33 additions and 21 deletions
|
|
@ -19,6 +19,18 @@ struct GeoJSONFeature: Codable {
|
|||
|
||||
// MARK: - GeoJSON Styling Properties
|
||||
|
||||
/// Extract feature name from properties, defaulting to empty string
|
||||
var name: String {
|
||||
// Check for "NAME" first (uppercase), then "name" (lowercase)
|
||||
if case .string(let value) = properties?["NAME"] {
|
||||
return value
|
||||
}
|
||||
if case .string(let value) = properties?["name"] {
|
||||
return value
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
/// Extract layer metadata from properties
|
||||
var layerId: String? {
|
||||
if case .string(let value) = properties?["layer_id"] {
|
||||
|
|
@ -147,10 +159,10 @@ struct GeoJSONFeature: Codable {
|
|||
/// Convert marker size to point radius
|
||||
var markerRadius: CGFloat {
|
||||
switch markerSize {
|
||||
case "small": return 8.0
|
||||
case "medium": return 12.0
|
||||
case "large": return 16.0
|
||||
default: return 12.0
|
||||
case "small": return 4.0
|
||||
case "medium": return 8.0
|
||||
case "large": return 12.0
|
||||
default: return 4.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -328,4 +340,4 @@ enum AnyCodableValue: Codable {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,23 +247,23 @@ struct MeshMapContent: MapContent {
|
|||
var overlayContent: some MapContent {
|
||||
// Get all features but filter by enabled configs
|
||||
let allStyledFeatures = GeoJSONOverlayManager.shared.loadStyledFeaturesForConfigs(enabledOverlayConfigs)
|
||||
|
||||
|
||||
|
||||
|
||||
return Group {
|
||||
ForEach(0..<allStyledFeatures.count, id: \.self) { index in
|
||||
let styledFeature = allStyledFeatures[index]
|
||||
let feature = styledFeature.feature
|
||||
let geometryType = feature.geometry.type
|
||||
|
||||
|
||||
if geometryType == "Point" {
|
||||
if let coordinate = feature.geometry.coordinates.toCoordinate() {
|
||||
Annotation("", coordinate: coordinate) {
|
||||
Annotation(feature.name, coordinate: coordinate) {
|
||||
Circle()
|
||||
.fill(styledFeature.fillColor)
|
||||
.stroke(styledFeature.strokeColor, style: styledFeature.strokeStyle)
|
||||
.frame(width: feature.markerRadius * 2, height: feature.markerRadius * 2)
|
||||
}
|
||||
.annotationTitles(.hidden)
|
||||
.annotationTitles(.visible)
|
||||
.annotationSubtitles(.hidden)
|
||||
}
|
||||
} else if geometryType == "LineString" {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct NodeMapSwiftUI: View {
|
|||
ContentUnavailableView("No Positions", systemImage: "mappin.slash")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var mapWithNavigation: some View {
|
||||
ZStack {
|
||||
MapReader { _ in
|
||||
|
|
@ -63,7 +63,7 @@ struct NodeMapSwiftUI: View {
|
|||
name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "?")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private var configuredMap: some View {
|
||||
baseMap
|
||||
.overlay(alignment: .bottom) {
|
||||
|
|
@ -91,7 +91,7 @@ struct NodeMapSwiftUI: View {
|
|||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var baseMap: some View {
|
||||
Map(position: $position, bounds: MapCameraBounds(minimumDistance: 0, maximumDistance: .infinity), scope: mapScope) {
|
||||
NodeMapContent(node: node)
|
||||
|
|
@ -112,7 +112,7 @@ struct NodeMapSwiftUI: View {
|
|||
}
|
||||
.controlSize(.regular)
|
||||
}
|
||||
|
||||
|
||||
private var lookAroundView: some View {
|
||||
Group {
|
||||
if scene != nil && isLookingAround {
|
||||
|
|
@ -123,7 +123,7 @@ struct NodeMapSwiftUI: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var altitudeView: some View {
|
||||
Group {
|
||||
if !isLookingAround && isShowingAltitude {
|
||||
|
|
@ -134,7 +134,7 @@ struct NodeMapSwiftUI: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var controlButtons: some View {
|
||||
HStack {
|
||||
Button(action: {
|
||||
|
|
@ -148,7 +148,7 @@ struct NodeMapSwiftUI: View {
|
|||
.tint(Color(UIColor.secondarySystemBackground))
|
||||
.foregroundColor(.accentColor)
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
|
||||
if scene != nil {
|
||||
Button(action: {
|
||||
if isShowingAltitude {
|
||||
|
|
@ -163,7 +163,7 @@ struct NodeMapSwiftUI: View {
|
|||
.foregroundColor(.accentColor)
|
||||
.buttonStyle(.borderedProminent)
|
||||
}
|
||||
|
||||
|
||||
if node.positions?.count ?? 0 > 1 {
|
||||
Button(action: {
|
||||
if isLookingAround {
|
||||
|
|
@ -182,7 +182,7 @@ struct NodeMapSwiftUI: View {
|
|||
.controlSize(.regular)
|
||||
.padding(5)
|
||||
}
|
||||
|
||||
|
||||
private func updateMapStyle(for layer: MapLayer) {
|
||||
UserDefaults.mapLayer = layer
|
||||
switch layer {
|
||||
|
|
@ -196,7 +196,7 @@ struct NodeMapSwiftUI: View {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func handleNodeChange() {
|
||||
isLookingAround = false
|
||||
isShowingAltitude = false
|
||||
|
|
@ -212,7 +212,7 @@ struct NodeMapSwiftUI: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func handleAppear() {
|
||||
UIApplication.shared.isIdleTimerDisabled = true
|
||||
updateMapStyle(for: selectedMapLayer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue