Plots2: New post location form: bug on the search-for-location

Created on 4 Dec 2019  ยท  18Comments  ยท  Source: publiclab/plots2

I am unable to type anything in to the input "By place name" and search.

FireShot Capture 093 - ๐ŸŽˆ Public Lab_ Post - localhost

This value is being passed to panMapToGeocodedLocation in leaflet-blurred-location... however the same input doesn't throw an error in locations/_form.html.erb - it doesn't search properly, that will have to be fixed as well, but it doesn't show "Oops, something went wrong!".

I will look into what is causing this!

bug

All 18 comments

thanks!!

On Wed, Dec 4, 2019 at 2:49 PM Natalie St Jean notifications@github.com
wrote:

I am unable to type anything in to the input "By place name" and search.

[image: FireShot Capture 093 - ๐ŸŽˆ Public Lab_ Post - localhost]
https://user-images.githubusercontent.com/49460529/70174812-9d22b800-16a3-11ea-93cb-f26900ac05f2.png

This value is being passed to panMapToGeocodedLocation in
leaflet-blurred-location... however the same input doesn't throw an error
in locations/_form.html.erb - it doesn't search properly, that will have
to be fixed as well, but it doesn't show "Oops, something went wrong!".

I will look into what is causing this!

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/6915?email_source=notifications&email_token=AAAF6J54XHUQJPE3BGJAYT3QXACSFA5CNFSM4JVNYZNKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4H6DLOFA,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAF6J4GQDZRK62SMIJWT23QXACSFANCNFSM4JVNYZNA
.

Can someone help me find the correct Javascript for this? In the views/locations/_form.html.erb file there is very clear Javascript that creates the blurredLocation object and calls panMapToGeocodedLocation. But I can't find that code anywhere for views/editor/rich.html.erb - is it in leaflet-blurred-location ? PL.Editor ?

So the error message appears to be from global maps and google's autocomplete API - probably failing on localhost because the site is not registered to their system. The error does not show up on the live site https://publiclab.org/post - this is what I get instead:

FireShot Capture 094 - ๐ŸŽˆ Public Lab_ Post - publiclab org

Which is the exact same behavior that happens on the popup modal:

FireShot Capture 095 - ๐ŸŽˆ Public Lab_ Extensible OSS - publiclab org

I'm guessing that this bug is somewhere in leaflet-blurred-location, I'll have to set that repo up and get it working.

But at the same time I still don't understand why I'm getting the error message on local on the post form, but not on the popup modal.

Hmm, sometimes the API key is present in the google maps API javascript
include, and possibly we have set it up differently between those two
instances?

Hmm, maybe we should compare these two lines:

https://github.com/publiclab/plots2/blob/5c0d96274bd0be15feba69d8f30093082402ace5/app/assets/javascripts/locationForm.js#L152

https://github.com/publiclab/plots2/blob/268352c1ed382f2b9a18e70c7e6eaced9a950336/app/views/layouts/application.html.erb#L17

We may use this API for multiple purposes, though, but this could be a good
starting point!

On Wed, Dec 4, 2019 at 3:59 PM Natalie St Jean notifications@github.com
wrote:

But at the same time I still don't understand why I'm getting the error
message on local on the post form, but not on the popup modal.

โ€”
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/6915?email_source=notifications&email_token=AAAF6J3YVYQU3DK7ZE5FNUDQXAKZHA5CNFSM4JVNYZNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF6PAPI#issuecomment-561836093,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAF6JZ65JSD2S5KTBZXZTLQXAKZHANCNFSM4JVNYZNA
.

Ok I'll look at that code and try to figure out the difference!

Hi @nstjean it sounds like you've found a couple possible overlapping bugs. If it's helpful to separate them into 2 issues that could help in the documentation! Thanks!

Hi @sagarpreet-chadha this is something we'd like to have a system test for!

Ok, I'll open an issue in LEL about the search getting stuck and not completing, and keep this one open for the "Oops something went wrong" issue with the form.

Oops, I meant leaflet-blurred-location!

Here we go, issue for the location search: https://github.com/publiclab/leaflet-blurred-location/issues/214

I searched all over the code to try to figure out the difference between these two forms and why they are behaving differently.

First I realized that the "Oops!" error statement is what should be showing, since there is an error with the google autocomplete.

Finally I realized that it's the timing of the popup that is the issue. When I included locations/form in a stand-alone non-popup page the error shows up just as it should!

FireShot Capture 097 - ๐ŸŽˆ Public Lab_ Stats - localhost

I believe the reason it's not showing up on the pop-up modal is simply because it pops up later, and the error is already being triggered on the page on reload.

Should I continue spending time figuring out how to get the timing corrected so the error shows up on the modal pop-up? Either way the issue will disappear when publiclab/leaflet-blurred-location#214 is solved.

Hey @nstjean ,
I think we should focus on the features first and we resolve all the bugs at the end. What do you think?
PS: If you think you are very close to finding the bug cause, you may continue else let's solve this at the end. Thanks!!!

I think that's a good idea. Thanks!

I just wanted to say i went to https://publiclab.org/post and tried using the input, i was able to use By place name and choose a location, but the map did not move and I got a loading spinner with the JS error:

Uncaught TypeError: Cannot read property 'geometry' of undefined
    at geocodeStringAndPan (Leaflet.BlurredLocation.js:1014)
    at Leaflet.BlurredLocation.js:956

I think maybe we're parsing the response of the locations api incorrectly? This may be a 3rd bug that has to be broken out, but it seems to match one of your above observations (from the live site, not the Ooops bug!

Quite possible!

OK! I've captured (lol) a sample response that I think we have to reconfigure around. I wonder when this changed and when it stopped working?

https://gist.github.com/jywarren/eec9fcec10528caaf463df6068846b0e

Can you try eliminating this variant of the bug by changing the parsing to match this? Then we can tackle Oops, something went wrong! after that!

Thanks, @nstjean !

Ah - let's move this most recent one -- the geometry one - over to https://github.com/publiclab/leaflet-blurred-location/issues/214 !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

first-timers[bot] picture first-timers[bot]  ยท  3Comments

first-timers[bot] picture first-timers[bot]  ยท  3Comments

first-timers[bot] picture first-timers[bot]  ยท  3Comments

grvsachdeva picture grvsachdeva  ยท  3Comments

noi5e picture noi5e  ยท  3Comments