Skip to content

hover / hoverOff never work for L.glify.lines() #182

@utilmind

Description

@utilmind

Hi! I investigated the issue why hover and hoverOff methods are never triggered for Glify lines...

Upon debugging static method tryHover in lines.ts I noticed that when it checks whether the hover point in inBounds(e.latlng, bounds) it accepts invalid (impossible) bounds, like the following ones:

{
    "_southWest": {
        "lat": -185.939713,
        "lng": 24.563612
    },
    "_northEast": {
        "lat": -66.970467,
        "lng": 71.27343
    }
}

It looks like lat and lng are mixed up.

After further investigation I also noticed that bounds constant in the TryHover method receiving incorrect input data, array of data.features instead of the featureCollection object,

const bounds = geoJSON(data.features).getBounds();

instead of

const bounds = geoJSON(data).getBounds();

I'm still testing it, then will prepare a patch / pull request if everything good...

UPD. data.features are not the issue, Leaflet's geoJSON() accept both array or object, so it's just micro optimization. But the real issue is that Leaflet's getBounds() returns bounds (lat/lng) in different sequence than expected for WebGL. lat/lng should be just swapped. This seems easier than swap lat/lng in all features of input data.

Or alternatively, something different should be used instead of Leaflet's getJSON().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions