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

OnClickMap works on PointSymbol but not on PointIcon #55

Open
xm3khs opened this issue Nov 18, 2024 · 12 comments
Open

OnClickMap works on PointSymbol but not on PointIcon #55

xm3khs opened this issue Nov 18, 2024 · 12 comments

Comments

@xm3khs
Copy link

xm3khs commented Nov 18, 2024

OnClickMap works on PointSymbol but not on PointIcon !!!

While representing makers on the map with the PointSymbol, the click works well.
After replacing PointSymbol with the PointIcon, clicking on the marker no longer works.
The OnClickMap event is only fired when clicking anywhere besides the markers.

OnClickMap method:

public async Task OnClickMap(RealTimeMap.ClicksMapArgs value)
{
    List<RealTimeMap.StreamPoint> foundPoints = (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
    );

    if (foundPoints is null || foundPoints.Count == 0) return;

    var point = foundPoints.Last();
    var pointAttributes = point.value as Attributes;

    if (pointAttributes is null) return;

    string url = $"/{pointAttributes.sourcetype}/{pointAttributes.reference}";
    await JSRuntime.InvokeAsync<object>("open", url, "_blank");
}
@ichim
Copy link
Owner

ichim commented Nov 19, 2024

Hello sir,

I think you want to open a page, with url from pointAttributes. It must also work with the icon. But I have to pay attention that the icon is anchored in the upper left corner. To orient yourself, you can put an icon and a marker.

@xm3khs
Copy link
Author

xm3khs commented Nov 19, 2024

I'm using version 2.2.2.2 and I have narrowed the issue to setting the appearance of a streampoint to a pointsymbol or pointicon along with the pointtooltip in both cases.

When I have a pointsymbol, putting the mouse over the marker, changes the cursor to the pointing hand and the tooltip appears.
I can click on it and it fires the onclickmap event. I've seen it while debugging on visual studio.

By changing the appearance to pointicon, visually the marker shows the tooltip and the cursor changes to the pointing hand, but clicking on it doesn't fire the event.
Just by moving the mouse a bit outside of the marker, when the cursor changes back to the default, if I click the map, then the onclickmap event fires correctly.

@ichim
Copy link
Owner

ichim commented Nov 19, 2024

In this case I have to check! I understand that the event is not fired on the PointIcon....

@xm3khs
Copy link
Author

xm3khs commented Nov 19, 2024

In this case I have to check! I understand that the event is not fired on the PointIcon....

We might need a click event for the pointicon instead of using the onclickmap event

@xm3khs
Copy link
Author

xm3khs commented Nov 19, 2024

Taking the chance that you will be looking at this, please notice that the click map event returns a list that may have more than one item.
I'm taking the last item of the list. Would it be possible to include in this library the markercluster for leaflet?

@ichim
Copy link
Owner

ichim commented Nov 20, 2024

Hello again,

OnClickMap event return ClicksMapArgs (only location). About which itmes do you say that there are more?

@xm3khs
Copy link
Author

xm3khs commented Nov 20, 2024

Hello again,

OnClickMap event return ClicksMapArgs (only location). About which itmes do you say that there are more?

I'm mentioning the code that I implemented on the onclickmap method (see on the first comment - foundpoints list)

It happens when multiple markers are placed in the same coordinates.

@ichim
Copy link
Owner

ichim commented Nov 20, 2024

I understood! You need to change the radius/distance (<=10). There is a query.

@xm3khs
Copy link
Author

xm3khs commented Nov 20, 2024

I understood! You need to change the radius/distance (<=10). There is a query.

Changing the radius doesn't help. I have multiple markers in the same exact coordinates. I would like to achieve this:
Screen_Shot_2015-06-03_at_9.02.51_PM-321939881.png

@xm3khs
Copy link
Author

xm3khs commented Nov 20, 2024

Getting back to the initial request...

I have set a tooltip using the predicate (p => true), which sets it for every marker.

While doing more tests where I used the zoom to decide which would be the appearance, I experimented switching between a default and a simplified version using pointsymbols in both cases. In this scenario the tooltip is always present when the mouse moves hover the marker.

When I decided to use the pointicon most of the time and switch to pointsymbol only when the zoom was higher, in order to have the possibility of clicking on it, I experienced something that can also be assigned to the use of the pointicon.

The tooltip ceases to appear when there's a change in the appearance and no longer appears unless I refresh the page.

@xm3khs
Copy link
Author

xm3khs commented Nov 21, 2024

Can you replicate what I described or do you need more details?

@xm3khs
Copy link
Author

xm3khs commented Jan 22, 2025

Hi Laurentiu Ichim, in order to fix this, please add the option bubblingMouseEvents set to true when adding the marker for PointIcon

...
bubblingMouseEvents | Boolean | default value: false | When true, a mouse event on this marker will trigger the same event on the map (unless L.DomEvent.stopPropagation is used).
... FROM - https://leafletjs.com/reference.html

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

2 participants