Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add centerMapAt util to MeshMap #918

Merged

Conversation

powersjcb
Copy link
Contributor

@powersjcb powersjcb commented Sep 8, 2024

What changed?

Added an animated centerMapAt utility function to the MeshMap View. It centers the view window on a location and resets map orientation to north and sets 3d views to top-down.

The create Waypoint feature now uses this to align/center the map on the selected location.

Why did it change?

centerMapAt will be necessary to support deep linking from node/chat views into the Mesh Map.

How is this tested?

Manually tested in Simulator.

Screenshots/Videos (when applicable)

centerMapAt.mp4

Checklist

  • My code adheres to the project's coding and style guidelines.
  • I have conducted a self-review of my code.
  • I have commented my code, particularly in complex areas.
  • I have made corresponding changes to the documentation.
  • I have tested the change to ensure that it works as intended.

@CLAassistant
Copy link

CLAassistant commented Sep 8, 2024

CLA assistant check
All committers have signed the CLA.

@powersjcb powersjcb changed the title Powersjcb/nodes map deep links add centerMapAt helper to MeshMap Sep 8, 2024
@powersjcb powersjcb changed the title add centerMapAt helper to MeshMap add centerMapAt util to MeshMap Sep 8, 2024
@@ -74,6 +86,9 @@ struct MeshMap: View {
.mapControlVisibility(.automatic)
}
.controlSize(.regular)
.onMapCameraChange(frequency: MapCameraUpdateFrequency.continuous, { context in
distance = context.camera.distance
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map zoom distance value isn't available through position (position.camera == nil). A few discussions I found recommended this solution.

# Run SwiftLint --fix on each file
for ((i = 0; i < count; i++)); do
file_var="SCRIPT_INPUT_FILE_$i"
file_path=${!file_var}
echo "Fixing $file_path"
$SWIFT_LINT --fix --path "$file_path"
$SWIFT_LINT --fix "$file_path"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--path was removed in a recent versions of swiftlint. This should be compatible with older versions of swiftlint since it's been deprecated for at least 2 years before that.

Widgets/WidgetsLiveActivity.swift Outdated Show resolved Hide resolved
@@ -92,6 +107,7 @@ struct MeshMap: View {
Logger.services.error("Unable to convert local point to coordinate on map.")
return
}
centerMapAt(coordinate: coordinate)
Copy link
Contributor Author

@powersjcb powersjcb Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally a quick hack for testing (since I don't have a way to access node data from Simulator), but centering the map on the location a waypoint is being proposed actually felt very intuitive so I decided to open this PR.

@@ -33,6 +33,7 @@ struct MeshMap: View {
@Namespace var mapScope
@State var mapStyle: MapStyle = MapStyle.standard(elevation: .flat, emphasis: MapStyle.StandardEmphasis.muted, pointsOfInterest: .excludingAll, showsTraffic: false)
@State var position = MapCameraPosition.automatic
@State private var distance = 10000.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this initial value will only matter when someone tries to deep link to a node before they've zoomed into an area on this map. (initial map zoom is set separately by MapCameraBounds(..., maximumDistance: .infinity),

It might be nice to tune this to whatever we find to be the most common ranges are when someone's wanting to view a point of interest. (be it waypoint or node)

@powersjcb powersjcb marked this pull request as ready for review September 8, 2024 02:30
@powersjcb powersjcb force-pushed the powersjcb/nodes-map-deep-links branch from 43a72aa to 089022d Compare September 8, 2024 04:47
@garthvh garthvh changed the base branch from main to center-meshmap September 20, 2024 02:42
@garthvh garthvh merged commit a40d194 into meshtastic:center-meshmap Sep 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants