ichim / LeafletForBlazor-NuGet

LeafletForBlazor NuGet Package - You can quickly add a map control to your Blazor application - 2.2.2.2 version. #12 issue, StreamLegend customization
https://www.nuget.org/packages/LeafletForBlazor#versions-body-tab
74 stars 9 forks source link

On click event on Points #24

Closed ehilgen closed 7 months ago

ehilgen commented 8 months ago

Hello,

Is there a way to get the GUID of a point based on a onclick on the Point. I have loaded the point via await realTimeMap.Geometric.Points.upload

Thank you.

ichim commented 8 months ago

Hello sir,

Not for this moment, sorry. The only possibility, at this moment, is to use a select() on the collection of points, but it is not an "elegant" solution :( For the future I will add a query based on the distance criterion.

ehilgen commented 8 months ago

Thank you for the fast response.

I did somthing simular already, by using CoordinateSharp

var pointCoordinate = new Coordinate(point.latitude, point.longitude, DateTime.Now); var distance = clickedCoordinate.Get_Distance_From_Coordinate(pointCoordinate); if (distance.Meters < 10) { var g = point.guid; }

ichim commented 7 months ago

Hello sir,

In the last version of the package, 2.0.4.2., I added the Geometric.Computations.distance() method, which allows the calculation of the distance between two points. With this method you can search for points located near one click:

@code{
     public  void onClickingMap(RealTimeMap.ClicksMapArgs value)
        {
            List<RealTimeMap.StreamPoint> findedPoints = (value.sender as RealTimeMap).Geometric.Points.getItems(point => (value.sender as RealTimeMap).Geometric.Computations.distance(
                    point, 
                    new RealTimeMap.StreamPoint() { latitude = value.location.latitude, longitude = value.location.longitude }, 
                    RealTimeMap.UnitOfMeasure.meters
                    ) <= 10
                );
        }
    }