-
Notifications
You must be signed in to change notification settings - Fork 43
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
[PIMS-248] BUG: zoom wrong location upon marker click #1814
Conversation
Fix is in place, but waiting to hear back from Lindsay on how she would like the centre and zoom behaviour to work before making my final changes and publishing for review. |
Code Climate has analyzed commit 117ca71 and detected 1 issue on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 80.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 54.8%. View more on Code Climate. |
Lindsay's suggestion was to remove the automatic centring and zooming. if (parcel.latitude !== '' && parcel.longitude !== '') {
// mapInstance.setView({ lat: parcel.latitude, lng: parcel.longitude }); // just centre
mapInstance.setView({ lat: parcel.latitude, lng: parcel.longitude }, MAX_ZOOM); // centre and zoom
dispatch(setMapViewZoom(MAX_ZOOM)); // determines how markers are clustered; call this if you zoom
} |
This update works well for me! Builds fine and no apparent issues. |
🎯 Summary
PIMS-248:
Issue
Addressing a bug where clicking a marker causes the map to centre and zoom to the wrong location. Usually it would centre on the default centre of the province on the first click, then on the previous marker on subsequent clicks.
Cause
Issue was caused by a useEffect in Map.tsx that set the map's view before the information was updated.
Fix
Removed the useEffect. Added command for centre and zoom to the call when the data is fetched upon marker click in PointClusterer.tsx.
Testing
Click some markers on the map. You should no longer be zoomed to unexpected locations.
🔰 Checklist