lolochristen / OpenLayers.Blazor

An Map component for Blazor based on OpenLayers with support for swisstopo swiss maps.
MIT License
42 stars 15 forks source link

Removing a marker does not remove it from the map #53

Closed vimception closed 7 months ago

vimception commented 7 months ago

Hello,

I think I'm hitting a bug, the shape of markers added to the map cannot be removed.

After adding a marker as follows:

var marker = new Marker(MarkerType.MarkerPin, coordinate, title)
{
            Id = id
};
map.MarkersList.Add(marker);

And subsequently removing the marker again:

var marker = map.MarkersList.First(_ => _.Id == id);
map.MarkersList.Remove(marker);

The marker remains visible on the map.

I'm not an expert, but I think the problem might be attributed to this line of code: https://github.com/lolochristen/OpenLayers.Blazor/blob/main/src/OpenLayers.Blazor/wwwroot/openlayers_interop.js#L978.

Here, you are only looking at the Geometries. In case of a marker, I would expect:

var feature = this.Markers.getSource().getFeatureById(shape.id);

Let me know if I can assist.

Thanks.

vimception commented 7 months ago

Working like a charm in +1.5.8. Thanks a lot for the quick fix @lolochristen.