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 ability to move map to user-entered coordinates using latitude and longitude text fields and button #166

Merged
merged 3 commits into from
May 15, 2023

Conversation

Asheshp23
Copy link
Contributor

Added latitude and longitude text fields and a button that allows the user to move the map to the entered coordinates.

Screen.Recording.2023-05-11.at.4.06.07.PM.mov


/// Map view to change simulated user's position
struct LocationView: View {
@ObservedObject var controller: SimulatorsController
let simulator: Simulator

@State private var latitudeText = "37.323056"
@State private var longitudeText = "-122.031944"
/// The location that is being simulated
@State private var currentLocation = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 37.323056, longitude: -122.031944),
Copy link

Choose a reason for hiding this comment

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

Might want to use constants here and in lines 18, 19 to easily change those in the future.

e.g.

DEFAULT_LAT = 37.323056
DEFAULT_LNG = -122.031944

18, 19 become:

    @State private var latitudeText = "\(DEFAULT_LAT)"
    @State private var longitudeText = "\(DEFAULT_LNG)"
Suggested change
center: CLLocationCoordinate2D(latitude: 37.323056, longitude: -122.031944),
center: CLLocationCoordinate2D(latitude: DEFAULT_LAT, longitude: DEFAULT_LNG),

@Asheshp23
Copy link
Contributor Author

@twostraws We've added latitude and longitude text fields and a button that allows the user to move the map to the entered coordinates.

Could you please review it and merge it?

@twostraws
Copy link
Owner

Great job – thank you very much!

@twostraws twostraws merged commit d285ffc into twostraws:main May 15, 2023
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.

None yet

3 participants