-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix: handle zero as a valid value for marker position #892
base: main
Are you sure you want to change the base?
fix: handle zero as a valid value for marker position #892
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
3db2368
to
f531337
Compare
Hi @s-montigny-desautels ! 👋 Is this PR still being actively worked on? Our team is experiencing this problem as well, and I was about to submit a PR when I found this. Thanks for looking into it 🙏 To pass checks and be ready for review, it looks like this PR just needs a supporting unit test update to gets the marker position... . Something along the lines of adding coordinate values of [0, 0], [0, N], [N, 0]: test("gets the marker position and returns a LatLng", () => {
// test markers created with LatLng and LatLngLiteral
[
new google.maps.LatLng(1, 1), { lat: 1, lng: 1 },
new google.maps.LatLng(0, 0), { lat: 0, lng: 0 },
new google.maps.LatLng(0, 1), { lat: 0, lng: 1 },
new google.maps.LatLng(1, 0), { lat: 1, lng: 0 },
].forEach((position) => {
const marker = new markerClass({ position: position });
if (markerClass === google.maps.marker.AdvancedMarkerElement) {
// TODO: consider getting more specific with the lat/lng checks
(marker as google.maps.marker.AdvancedMarkerElement).position =
position;
}
expect(MarkerUtils.getPosition(marker)).toBeInstanceOf(
google.maps.LatLng
);
});
}); Is this something I can help with, or would you prefer to add it? |
Hi, thanks for the info, I didn't know I needed to add a new test for this. I can add those tests, but it's kind of pointless, since we can't actually test that the Lat & Lng is set to 0, since |
@s-montigny-desautels 🤔 I can't think of anything right this moment, but let me try out some things when I'm back in the office next week. @wangela it looks like you're most active on PRs for this repo. Would you happen to have a suggestion for the unit tests or someone we could reach out to for help? (I didn't immediately see anything in the Contribution guide.) |
@s-montigny-desautels Sorry for the delay. Here's a draft PR with the approach I was thinking about for the solution and testing--needs work, but hopefully this conveys the idea: To run the tests, execute at the command line: The In the mean time, our workaround is to intercept values of |
Use null check to prevent 0 value to be falsy.
Also, the code
new google.maps.LatLng(null);
return a marker with the coordiate (NaN, 0) and it break the SuperCluster algorithm.Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #891 🦕