BlazorMaps icon indicating copy to clipboard operation
BlazorMaps copied to clipboard

Click event on map marker

Open ledpup opened this issue 3 years ago • 0 comments

I have the following code for resolving a map marker back to a location (where I got the lat longs from originally.)

    private async Task HandleMapMouseEvent(MouseEvent mouseEvent)
    {
        var lat = Math.Round(mouseEvent.LatLng.Lat, 1);
        var lng = Math.Round(mouseEvent.LatLng.Lng, 1);
        var newLocation = Locations.Single(x => Math.Round(x.Coordinates.Latitude, 1) == lat && Math.Round(x.Coordinates.Longitude, 1) == lng);
        await SelectedLocationChanged(newLocation.Id);
    }

This works but it seems like a strange way to do it. Why not pass an ID to the map marker when I'm creating it, and then find via the ID, rather than deal with rounding issues with lat long?

There doesn't appear to be a way to do that. Am I missing something?

ledpup avatar Dec 13 '21 08:12 ledpup