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

Calculate viewport bounds when searching for a place #543

Merged
merged 5 commits into from
Oct 31, 2024

Conversation

wbazant
Copy link
Collaborator

@wbazant wbazant commented Oct 27, 2024

Closes #389 .

Center is in Mercator space, thanks to Ethan for explaining how to get it in #389 (comment) .

getZoom and getBoundsForScreenSize are AI generated and appear to work. I don't quite understand especially the project/unproject helper functions and their relation to latLngToMercator/mercatorToLatLng .

I could check that the centre works by logging the bounds used, as well as google's getBounds() in src/redux/mapSlice.js .

To check center, I compared the calculated center to fitBounds + getCenter.

For zoom, I just checked a few examples at a few different scales and it matched - I originally had the zoom wrong and I've dismantled the testing jig that logged values for me. Can't be too far off!

As a bonus I've found a bug in the API when testing something - falling-fruit/falling-fruit-api#43 - but then I've realised I used the wrong code for calculating bounds (the implementation with padding around the viewport did not seem to correctly work, but getting the bounds for zoom + center + width + height seems to be reliable).

@ezwelty
Copy link
Collaborator

ezwelty commented Oct 31, 2024

@wbazant Nice! I confirm that results are identical searching in map or list and moving between them.

I do notice however that when a list url is loaded, the map first flashes on (presumably so that it is available to the list). Is this still necessary, or can this behavior now be removed?

e.g. http://localhost:3000/list/@47.6856328,-122.3485287,17z

@wbazant wbazant merged commit e4cf19c into falling-fruit:main Oct 31, 2024
1 check passed
@wbazant
Copy link
Collaborator Author

wbazant commented Oct 31, 2024

Not necessary and not easy either, I've made a follow-up issue. Thanks for QAing and pointing that out!

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

Successfully merging this pull request may close these issues.

Searching in the list view sometimes doesn't update locations on list
2 participants