Blazor Map component zoom issue

1 Answer 66 Views
Map
Jacek
Top achievements
Rank 1
Jacek asked on 30 Oct 2023, 05:10 PM
I've got a strange issue with zooming via mouse scroll. After every change in marker and center (I need both of them, so I didn't test it separately) the zoom is running faster and faster, but only when using mouse scroll. Am I doing something wrong or it's a bug?
You can test it with the code below and clicking the Random button on top a few times and than trying to mouse scroll. It's not a critical issue but quite annoyance. Using `MapRef.Refresh()` instead of `StateHasChanged()`seems to not fix the issue.

<TelerikButton OnClick="() => Random()">Random</TelerikButton>

<TelerikMap Center="@Center" Zoom="17">
    <MapLayers>
        <MapLayer Type="@MapLayersType.Marker"
                  Data="@MarkerData1"
                  LocationField="@nameof(MarkerModel.LatLng)"
                  TitleField="@nameof(MarkerModel.Title)" Shape="MapMarkersShape.Pin">
        </MapLayer>

        <MapLayer Type="@MapLayersType.Tile"
                  Attribution="@Attribution"
                  Subdomains="@Subdomains"
                  UrlTemplate="@UrlTemplate">
        </MapLayer>
    </MapLayers>
</TelerikMap>

@code {
    public string[] Subdomains { get; set; } = new string[] { "a", "b", "c" };
    public string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png";
    public string Attribution { get; set; } = "&copy; <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>";
    public double[] Center { get; set; } = new double[] { 60.268107, 97.744821 };

    public List<MarkerModel> MarkerData1 { get; set; } = new List<MarkerModel>()
    {
        new MarkerModel()
        {
            LatLng = new double[] { 60.268107, 97.744821 },
            Title = "Austin, TX"
        }
    };

    public void Random() {
        var marker = MarkerData1.First();
        Random random = new Random();
        var lat = random.NextDouble() * 90;
        var lng = random.NextDouble() * 90;
        marker.LatLng = new double[] { lat, lng };

        Center = new double[] { lat, lng };
        StateHasChanged();
    }

    public class MarkerModel
    {
        public double[] LatLng { get; set; }
        public string Title { get; set; }
    }
}

1 Answer, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 02 Nov 2023, 07:35 AM

Hi Jacek,

I confirm that the issue at hand is related to a known bug in the scrolling behavior. This issue has already been reported publicly under the title: 'Unify the zoom action behavior when using the plus button and mouse wheel'. I voted there on your behalf and raised the priority.

Once the fix is implemented, it will address the scenario you've encountered. To stay updated on its progress, you also have the option to subscribe to the item and receive email notifications for status updates.

Regards,
Hristian Stefanov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources!
Maxime
Top achievements
Rank 1
commented on 11 Jan 2024, 04:17 PM

Hello,

I have the same problem.

I have voted for the feature and hope it will be planned soon.

Regards,
Maxime Lavergne

Tags
Map
Asked by
Jacek
Top achievements
Rank 1
Answers by
Hristian Stefanov
Telerik team
Share this question
or