-
Notifications
You must be signed in to change notification settings - Fork 265
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
Clean up map view info window #418
Clean up map view info window #418
Conversation
Using the built-in marker eliminates the need for the NumberedCircle class and significantly simplifies the code, since now the Google API takes care of positioning the marker, the label, and the info window. This also solves the overflow and lack of padding problems that the old info window had.
8266608
to
0ccc52a
Compare
Some tests failed, so I'll go look into that, but the screenshot sure looks nice! |
For some reason this breaks a few cucumber tests. There is a supporting ruby function, see: That set of functions errors out for 4 of the tests now. These are: The error messages look pretty much like this all 4 times:
(The innermost error is " There are also two tests where searching for an HTML element by its Here
and Here
|
I don't know what's making the tests not pass. The website seems to exhibit normal behavior when I use it, i.e. it searches and displays bathrooms correctly. I'll try and debug the tests but that might take a while since I'll be busy over the next few days. |
I agree that the code looks normal to me, and it definitely works. These errors are also really strange to me. In order to hopefully save some time on manual debugging, or at least narrow the bug hunt a bit, it might be worth submitting each commit to a PR one at a time. That would let Travis CI do a full run on each commit. I have in mind a way to do this from the command line, but perhaps you already know exactly how, so feel free to ignore; Regardless, I'm not going to hint at a way without explaining it, so here goes: If you preserve these commits (for example, just make an identical branch with you can switch back to ( and then merge your commits back, one at a time, i.e:
and then |
0ccc52a
to
3f7f316
Compare
This is the standard approach and having mixed tabs and spaces isn't good.
Taking the outer html of the container element to the container itself. This is useful because the container has the markerPopup class.
It seems like the first commit already broke the tests. |
From here on the first commit's tests:
The tests failing on the first commit are the same as the ones that failed previously for the PR as a whole. All that from changing the whitespace in the maps javascript file? Kinda weird. |
Actually, the first commit is right below the top post. It's titled "Use google maps built-in custom marker". In there, I deleted the |
Okay, yep. Anyway, failing tests are the same after commit 1, 2, and 3, i.e. nothing additional breaks later than commit 1, so I guess the troubleshooting can be limited to commit 1. Hopefully that narrows it down a bit. (I'm not that great with JavaScript, but I'll look it over anyway.) |
Thank you @DeeDeeG! I'm gonna be busy over the next couple of days so I probably won't be able to work on this that much. |
So we're assuming there is some obscure thing wrong with According to this online JavaScript validator, [link], there are some undefined functions (among other, possibly more-minor errors):
Maybe that has something to do with it? |
@DeeDeeG Thanks for taking a look. Those are all variables defined outside of During testing, working from the original commit, I've deleted the entire NumberedCircle class, which would cause the bathrooms to not show up on the map at all, and the tests still pass. Taking a further look, most of the steps for testing the map feature have been previously commented out, in |
This is what was breaking the tests. The headless browser doesn't support arrow functions, which most modern browsers support now. This was breaking all the tests.
@DeeDeeG Fixed it! In the end the problem was me using an arrow function |
Nice! So this looks merge-ready to me. (Ideally reviewed by someone who gets JavaScript better than I do, but this seems pretty simple.) Any thoughts on how to make the tests better? Maybe some broader (less hyper-narrow, less feature-oriented) error steps, for example add a more generic "page should not show a big huge error message"? (Not that that would help with this PR, I think.) Maybe there is a way to make PhantomJS, the headless browser we use, surface an error message of its own? |
@mi-wood, would you like to review this, now that the Travis CI build is passing? I think it would be better to have a reviewer who knows more about JavaScript, but I am comfortable with merging it, since it works in testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment, but I this seems to get rid of a lot of code, which is nice :)
My one question is if this makes #298 harder? Do the helper map classes included in their licensing, or is it separate from the data? And if we decide to move off of google maps, will these need to be changed back to our custom objects?
app/assets/javascripts/maps.js
Outdated
// Create Icon | ||
var circleIcon = { | ||
url: circleMarkerImage, | ||
size: new google.maps.Size(37, 37), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these values coming from? Can we move them out into constants DEFAULT_WIDTH
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I measured the size of the image. It's in a constant now.
As per your question, when we get to #298, we'll probably need to use another library to do this, so it'll be a bit of work, but the old solution depended on the Google Maps API as well, just not as much. Also, it'll be a better idea to use a library to avoid reinventing the wheel, so I think moving on we just won't use custom objects. From my understanding, OpenStreetMap is mostly just the data, and to deploy it we need some other library. Leaflet, suggested by https://wiki.openstreetmap.org/wiki/Deploying_your_own_Slippy_Map, seems like a good choice and it has a powerful API for markers and popups. |
I'm good with this 👍 |
…etail Clean up map view info window
…etail Clean up map view info window
Context
Summary of Changes
NumberedCircle
class by using Google's built-in custom marker and info window system. For details please see my commit message.Checklist
Screenshots
Before
After