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 Google reverse lookup in getPlacenameFromCoordinates #232
Conversation
60100cd
to
fe8154c
Compare
fe8154c
to
ae024b2
Compare
I found that the API call was being triggered continuously during a map move, it was firing off a huge number of API calls. Now it will only update the location name once at the end of the map move! I added in the option to set a default message if the google api call fails. This way I can control what shows up in the location modal.
If all looks good I'll add it to the documentation! |
I think I did something wrong when publishing to gh-pages. :( It's broken now. |
hm, i think @crisner has recently published to gh-pages on LEL, maybe can
offer some input? did you include the node_modules folder and the dist
files? Don't stress!
…On Thu, Jan 9, 2020 at 5:00 PM Natalie St Jean ***@***.***> wrote:
I think I did something wrong when publishing to gh-pages. :( It's broken
now.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#232?email_source=notifications&email_token=AAAF6J2TFKNGLL5BIHB3MM3Q46M7NA5CNFSM4KE457V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIR55GA#issuecomment-572776088>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JZOM5TFJLWJD5QT5CDQ46M7NANCNFSM4KE457VQ>
.
|
@nstjean, I see a bunch of 404 errors. Check if the node modules exist in the gh-pages branch. If not, you will need to push them along with your dist files if you haven't pushed them already. Let me know how this goes. :) |
Yes that fixed it! It works now. :) |
Ok the gh-pages is up to date with this branch: There is still an error in the response from google: "API keys with referer restrictions cannot be used with this API."
|
Hm, ok, I'll try to make another key with a different type of restriction. |
Ah, ok, so that didn't make sense because it's supposed to be an HTML referrer restriction for client-side requests. The issue may be different:
I'll be sure the existing key has permissions for the Google Javascript API. |
src/core/Geocoding.js
Outdated
country = result.results[i].formatted_address; | ||
} | ||
$.ajax({ | ||
url:"https://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+lng + "&key=AIzaSyAOLUQngEmJv0_zcG1xkGq-CXIPpLQY8iQ", |
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.
So i guess we have to change this to the JS version?
Here seems to be the docs for that: https://developers.google.com/maps/documentation/javascript/geocoding#ReverseGeocoding
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.
Ahhh!! Ok! I will get it switched over.
@jywarren @sagarpreet-chadha @crisner Please take a look at the console on https://publiclab.github.io/leaflet-blurred-location/examples/index.html
|
@nstjean, I am not sure why lat and lng has functions for values but calling it as |
You could perhaps call the lat and lng functions and store them in variables to use here?
|
Upon looking at different posts it looks like you will have to get the lat and lng values as |
Thank you!! I was so frustrated yesterday I had to walk away. |
This works now! You can see it in action on gh-pges: https://publiclab.github.io/leaflet-blurred-location/examples/index.html All tests are passing but it's giving me a warning |
The other question I have is about the format of the Placename. When you are zoomed out it displays only the Country, which is fine. When zoomed in sometimes it shows city, zipcode, country, or zoomed in further displays street number/name, city, zipcode, country. The format changes from country to country. So let me know if the location names that display are what we want or if it needs to be changed. |
Hey, |
Yes that is true. I'm not sure how we would go about testing things that
rely on the Google api data.
…On Tue, Jan 14, 2020, 11:40 AM Sagarpreet Chadha ***@***.***> wrote:
Hey,
We do not have tests for placename, right? If we will write tests for it,
then that test will fail.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#232?email_source=notifications&email_token=ALZLKMKKKHTKFUK2UHED7V3Q5XTF7A5CNFSM4KE457V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI5JDVI#issuecomment-574263765>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZLKMPGZLPW7AXCTM2F7BDQ5XTF7ANCNFSM4KE457VQ>
.
|
Okay i was thinking about this, one way to test is mocking data. |
Ok! Sounds good!
…On Tue, Jan 14, 2020 at 12:28 PM Sagarpreet Chadha ***@***.***> wrote:
Okay i was thinking about this, one way to test is mocking data.
But this tests should be part of end to end tests (which will test API and
its effect on UI). We can ignore the warning for now i think, for writing
e2e test i would prefer different framework that is seperate discussion.
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#232?email_source=notifications&email_token=ALZLKMKPDZY2VVEZDYZKODTQ5XY3FA5CNFSM4KE457V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEI5OMQI#issuecomment-574285377>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALZLKMOVML5AE2UA62MJVLLQ5XY3FANCNFSM4KE457VQ>
.
|
In order to have the placename field be overwritten sometimes but left alone at other times I've included a check for the value of a new data attribute: If If |
I bumped the version to 1.6.0 for adding the new placename data attribute check. |
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.
Looks good to me :)
This is awesome. Thanks all for getting this figured out! I'll publish shortly! |
Just went over this with @jywarren. Awesome! 🎉 |
😄 and published as |
want us to bump dependabot? |
I just did that! watch for a PR on plots2! |
Issue #231
I'm considering adding in a option to set the displayed value as something other than "Location unavailable" - in plots2 I'd like for it to be blank if there's an error.