Skip to content

Make the map refresh when there is a change in the internet connection #27112

Closed as not planned
@eduardoagr

Description

@eduardoagr

Description

I would like the map to re-render itself when the internet is back on.

For example, if you create an application and the internet gets cut off, the map cannot be rendered. When the internet is back on, the map will not check if there is an internet connection to be re-rendered. This feature would allow the map control to detect changes in the network state and automatically re-render the map when the internet connection is restored.

Public API Changes

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

public partial class MapViewModel : ObservableObject
{
    [ObservableProperty]
    private bool _isInternetAvailable;

    public MapViewModel()
    {
        // Constructor logic
    }

    partial void OnIsInternetAvailableChanged(bool value)
    {
        if (value)
        {
            RefreshMap();
        }
    }
private void RefreshMap() {
if (mapView != null) {
 
 mapView.Reload(); 

 }
}

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="YourNamespace.YourPage"
             xmlns:vm="clr-namespace:YourNamespace.ViewModels">
    <ContentPage.BindingContext>
        <vm:MapViewModel />
    </ContentPage.BindingContext>

    <StackLayout>
        <MapView x:Name="mapView"
                 IsInternetAvailable="{Binding IsInternetAvailable}" />
    </StackLayout>
</ContentPage>

Intended Use-Case

I have an app, that shows a pop up when the internet is down and when the internet is back up, the popup disappear and I want my map to get re-renderer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions