Syntaf / slacklinegroups_legacy

A tool for aggregating and visualizing slackline group information from Slackchat.
GNU General Public License v3.0
2 stars 3 forks source link

Write logic to replace zoom offset #20

Open Syntaf opened 6 years ago

Syntaf commented 6 years ago

Zoom offset doesn't seem perfect, and for some reason an occasional group is placed off screen when zooming (see the Iceland group for example).

A better solution would be to set a desired location in the screen (10% from the bottom, 20% from the bottom, etc.. etc..) and calculated the desired lat/lon on the fly. This way no offset is needed and the groups are guaranteed to show up at a specific location.

Syntaf commented 6 years ago

Work has been done on this issue, but more logic needs to be refactored/added to fully implement this.

The current new approach uses map.project and map.unproject.

When a group is clicked, we first find the pixel X,Y location of the group on the map. We then use this pixel X,Y location, some constant heights from the UI, and a magic constant to calculate how much our offset should be.

The problem with this approach is that all calculations are done at the initial zoom level, which don't work when the map zooms to a specific location. If our offset is calculated to be 10 at zoom level 3, then our group could be way off from the camera view when that offset of 10 is applied during zoom level 7.