Reset GoogleMap and change location

I am using a RadzenGoogleMap. I have it set to load a specific set of Pins, and I can successfully change them based on what selections the user has made.

Is there a way to reset the map or otherwise cause it to redraw?

I know changing the "Center" won't cause the map to redraw -- but is there some way to force it?

Hi @Carthax,

RadzenGoogleMap will update if you change its Center, Zoom or Markers properties.

So I have this Map:

    <RadzenGoogleMap @ref=Map style="height: 700px; margin-bottom: 10px"
                     Center=@(new GoogleMapPosition() { Lat = 35.72053555611487, Lng = -86.56288218012577})
                     Zoom=8
                     ApiKey=
                     MarkerClick=@OnMarkerClick
                     Data="Markers">
    </RadzenGoogleMap>

...and the applicable code looks like this:

private RadzenGoogleMap? Map { get; set; }

    private async Task SelectCounty(object value, string name)
    {
        var Center = new GoogleMapPosition();
        if (value != null)
        {
            Permittees = new();
            foreach (var info in Infos)
            {
                if (info!.County.ToUpper() == value!.ToString()!.ToUpper() && info.Loc_Lat != 0 && info.Loc_Lon != 0)
                {
                await JSRuntime.InvokeVoidAsync("console.log", "County Match");
                    Permittees.Add(info!);
                    Cities.Add(info.City);
                    display = "block";
                    var c = Counties.Where(x => x.Name.ToUpper() == value.ToString()!.ToUpper()).FirstOrDefault()!;
                    Center = new() { Lat = c!.Lat, Lng = c!.Lng };
                }
            }
        }
        else
        {
            foreach (var info in Infos)
            {
                Permittees.Add(info);
                display = "none";
            }
        }
        UpdatePins(Center);
    }

private void UpdatePins(GoogleMapPosition position = null!)
    {
        Markers = new();
        foreach (var info in Permittees)
        {
            if (info.Loc_Lat != 0 && info.Loc_Lon != 0)
            {
                var label = String.Format("{0}: {1}", @info.SC_ReportID, @info.NameLFM);
                Markers.Add(CreateMarker(label, info));
            }
        }
        if (Map != null)
        {
            if (Markers.Count != 0 && Markers.Count >= 25)
            {
                Map.Center = new GoogleMapPosition() { Lat = 35.72053555611487, Lng = -86.56288218012577 };
                Map.Zoom = 8;
            }
            else
            {
                if (position != null)
                {
                    Map.Center = position;
                    Map.Zoom = 10;
                }
            }
            StateHasChanged();
        }
    }

Here is the original map after adding all the pins:

Here is the map after updating the pins to just those in Cheatham County, TN:

For reference, Cheatham County (the test case of 36.2611, -87.0867) is northeast of Nashville, and the map is centered at a location nearly 30-35 miles straight south of Nashville as the crow flies.

This map settings are correct in the IDE at this point, with the Center set to Cheatham County's geocoordinates and the Zoom set to 10. I can see when I step through my code.

...but the map never updates. The issue is the same, whether I have StateHasChanged() in the UpdatePins() procedure or not.

What am I doing wrong?

You are updating the chart properties. Bind them to properties instead e.g.

<RadzenGoogleMap Zoom=@zoom />
zoom = 10;

Oh, jeez... That was way too easy.

To my credit, I had tried that previously. To my detriment, I was still attempting to set the chart properties directly, by setting Map.Zoom = zoom.

::sigh::

Thank you.