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

Current user location #3

Open
Limonlol opened this issue Dec 30, 2019 · 4 comments
Open

Current user location #3

Limonlol opened this issue Dec 30, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@Limonlol
Copy link

Need func or property to get user location one time

@Alex009 Alex009 added the enhancement New feature or request label Feb 19, 2020
@OrhanTozan
Copy link
Contributor

OrhanTozan commented Oct 2, 2020

You can do it with this:

locationTracker.startTracking()
val location = locationTracker.getLocationsFlow().first()
locationTracker.stopTracking()

@plusmobileapps
Copy link

@OrhanTozan Is it possible to get the user's current location by using that provided code? Or is there somewhere where startTracking() and stopTracking() must also be called before and after that?

@OrhanTozan
Copy link
Contributor

@plusmobileapps you're right. I edited my answer.

@plusmobileapps
Copy link

What's funny is in the 13 minutes of me commenting that, I figured that out. To the original issue posted here, it would be nice to add a new function to LocationTracker itself that could handle this for the consumer as to not worry about that specific detail if you only ever want one location and not continuously track the user since this is what I added in my own project.

class LocationTracker {

    suspend fun getCurrentLocation(): LatLng {
           startTracking()
           val currentLatLng = getLocationsFlow().first()
           stopTracking()
           return currentLatLng
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants