Skip to content

[Feat] improve performance significantly by selectively updating the Polygon options #524

Open
@nimlevy

Description

@nimlevy

Target Use Case

We are using the library to give our clients the ability to select zip code areas on the Google Map. Imagine a map marked with zip code boundaries, the user can hover to see details and then click to select the zip code (changing opacity and adding to a list)

Proposal

The issue (somewhere between a bug and a feature) is that the dependencies of the Polygon example (and probably the other geometry components as well) where the polygon.setOptions is called, are setting the options every time the mouse hovers over the polygon's area.
Updating the dependencies to the specific properties that would affect the rendering of the polygon (e.g. the strokeOpacity, fillOpacity, etc.) drastically improves performance.

I am not sure what is the best way to go about it, but the assumption stated in the following comment is, unfortunately, incorrect.

// update PolygonOptions (note the dependencies aren't properly checked
// here, we just assume that setOptions is smart enough to not waste a
// lot of time updating values that didn't change)

In other words - the setOptions is not smart enough.

Note: I have seen a drastic decrease in performance (color changes, info window's movement, etc. were lagging badly) when using the original format of paths (array of lat & lng) that React's dependency check could not properly compare

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions