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 support for watchPosition #3

Open
dpaquette opened this issue Mar 8, 2018 · 4 comments
Open

Add support for watchPosition #3

dpaquette opened this issue Mar 8, 2018 · 4 comments

Comments

@dpaquette
Copy link
Contributor

The watchPosition method seems useful. We should support it.
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition

@dpaquette
Copy link
Contributor Author

I got this working on the plane. I will try to get it checked in and published soon

@dpaquette
Copy link
Contributor Author

This is done. I just need to update the Readme with a sample so people know how to use it

@joseftw
Copy link

joseftw commented May 9, 2019

Hello!
Im trying to get the WatchLocation feature to work, but it seems like it never fires, my breakpoint in OnWatchLocationCallback is never hit. Have I missed something obvious?
GetLocationAsync works like a charm :)

@functions
{
    private string _position = string.Empty;
    Location _location;

    protected override async Task OnInitAsync()
    {
        await LocationService.WatchLocation(OnWatchLocationCallback);
        _location = await LocationService.GetLocationAsync();
    }

    private void OnWatchLocationCallback(Location obj)
    {
        _position = $"{obj.Latitude} - {obj.Longitude} - {obj.Accuracy}";
    }
}

@soend
Copy link

soend commented Nov 5, 2019

Hello!
Im trying to get the WatchLocation feature to work, but it seems like it never fires, my breakpoint in OnWatchLocationCallback is never hit. Have I missed something obvious?
GetLocationAsync works like a charm :)

@functions
{
    private string _position = string.Empty;
    Location _location;

    protected override async Task OnInitAsync()
    {
        await LocationService.WatchLocation(OnWatchLocationCallback);
        _location = await LocationService.GetLocationAsync();
    }

    private void OnWatchLocationCallback(Location obj)
    {
        _position = $"{obj.Latitude} - {obj.Longitude} - {obj.Accuracy}";
    }
}

Hello,

Did you end up figuring this out? I tried it also and it only seemed to work when i call the WatchLocation method from OnAfterRenderAsync override.
Example:

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await LocationService.WatchLocation(OnWatchLocationCallback);
        StateHasChanged();
    }

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

No branches or pull requests

3 participants