studioespresso / craft-easyaddressfield

Easy Address Field is the easiest way to add an address to your entries. Enable the fields you want for the address, automatically get the coordinates for an address and place the marker exactly where you want it.
https://plugins.craftcms.com/easy-address-field
Other
3 stars 3 forks source link

Geocode producing wrong coordinates for specific addresses #24

Closed saltymouse closed 4 years ago

saltymouse commented 4 years ago

I'm using the plugin to get the geocode coordinates from addresses for Leaflet maps on the front end. This works great, but one of the addresses I have is geocoded incorrectly. Is there any way to debug the geocoding process to see why this is happening?

I've enabled the geocoding API on my Google account, and it works for all other addresses. Here's an example address that isn't working for me: 19510 144th Ave NE Suite A-6, Woodinville, WA 98072

In the Easy Address Field plugin, this generates a coordinate in Nebraska, not Washington state.

Entering this same address into Google's online geocoder demo, however, shows the correct address location in WA: https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple

janhenckens commented 4 years ago

Hey @saltymouse, How are you entering the address in the field?

When I enter it like this, it seems to get the correct coordinates.

image
saltymouse commented 4 years ago

Hi Jan, thanks for the the reply.

Indeed, I had entered the address just as your screenshot shows. However, I think I may have solved the issue after playing around with it for a bit.

I got the same address (above) to produce the correct coordinates only after clearing both the latitude and longitude fields, then re-saving the Craft entry (thus generating new coordinates based on the address fields). It looks like the coordinates aren't refreshed unless cleared-out first (then re-saved). Is this correct?

I was under the impression the coordinates would regenerate upon each save regardless of whether or not there were old values in there. My problem was: I had set the coordinates fields to hidden (in the field's settings) so I didn't realize I could empty them to begin with.

If this is working as expected, I think it might be useful to make note of this refresh method in the README somewhere. If not, perhaps a refresh button, or just regenerate the coordinates upon each Craft entry save.

janhenckens commented 4 years ago

Hey there

That is indeed correct, the coordinates are only looked up on the first save, to not make repeated requests (= costs) to the geocoding API.

And you're also correct that that should be in the readme, I'll get on that right away!

If you have any other questions, feel free to reach out!