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

Adding AddRange method to ShapesList #98

Open
frankvandenbergh opened this issue Jan 2, 2025 · 2 comments
Open

Adding AddRange method to ShapesList #98

frankvandenbergh opened this issue Jan 2, 2025 · 2 comments

Comments

@frankvandenbergh
Copy link

First of all: best wishes and thanks for this component

I make use of OpenStreetMap. Setting markers is a bit slow (I've about 2000 markers, with about all different icons). Is the code below correct or is there a better approach or could you add an AddRange method?

<OpenStreetMap>
    <Layers>
        <Layer @ref="_layer" LayerType="LayerType.Vector" SourceType="SourceType.Vector">
        </Layer>
    </Layers>
</OpenStreetMap>


private void DrawSensorData()
{
    if (sensorData != null && sensorData.Count > 0)
    {
        _layer.ShapesList.Clear();
        int radius2 = 13;
        foreach (var sensor in sensorData)
        {
            Marker marker2;
            string svg = "data:image/svg+xml;utf8, " + MarkerHelper.CreateSensorSvg(SelectedParticulate, sensor.Value);
            marker2 = new Marker(new Coordinate(sensor.Longitude, sensor.Latitude), svg, radius2 * 2, radius2 * 2, radius2, radius2);
            marker2.Popup = true;
            marker2.Properties.Add("SensorId", sensor.Id);
            marker2.Properties.Add("Value", sensor.Value);
            marker2.Properties.Add("MinValue", sensor.MinValue);
            marker2.Properties.Add("MaxValue", sensor.MaxValue);
            marker2.Properties.Add("Address", sensor.Address);

            _layer.ShapesList.Add(marker2);
        }
    }
}
@MTD-Thomas
Copy link

Indeed ShapesList or LayersList are both ObservableCollection so adding one at a time trigger the event each time, when you know you have a complete list it could be better to add everything once.

@lolochristen
Copy link
Owner

lolochristen commented Jan 17, 2025

2.4.0 released with a AddRange method on ShapesList Collection for bulk inserts.

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