Hello, thank you for the work on this module.
One issue I'm having is that if an address isn't required, the module still renders a blue image (assuming it's just placing me somewhere in the middle of the ocean). Or if my address field is set to only allow one country (US in my case) and the country field is hidden, the map is placed somewhere in the middle of the country.
What I think is needed is some check in addressfield_staticmap_field_formatter_view() to see if there is:
- An address at all
- The address provides enough information to be useful
The second one is a bit more arbitrary so I'm not particularly sure how a criteria would be set. Right now I'm checking agains locality, admin area and postal code (again, US specific address). Any ideas on the best approach for this?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2066509-empty-address.patch | 1.61 KB | jnettik |
Comments
Comment #1
tirdadc commentedStrangely enough, this doesn't occur with the block, only with the field formatter. I'll add a check to cover that an address is set for now and it can be improved from there.
EDIT: this is the same check that was performed in the block display, ie do not display anything if only the country is set (which is the equivalent of an empty address). http://drupalcode.org/project/addressfield_staticmap.git/commitdiff/0383f46
Comment #2
tirdadc commentedThe difficult part in addressing the second issue is that the address field' elements (locality, area code, etc...) vary depending on the country's format, so whatever minimal amount of information one would expect before rendering a map a) would vary based on that and b) need to be dynamically configurable (ex: you get a list of checkboxes for each address component in the field formatter and you then set which ones are mandatory for rendering).
I'm closing this for now as the original bug has been dealt with, but the second task can be spun off into a feature request.
Comment #3
jnettikI went ahead and created a feature request for this at #2083461: Allow configuration of required information for when a map gets rendered. .
Comment #4
jnettikSo after updating to the latest dev I was still having an issue when there were no address results. In my case $data_cleaned had no results at all. So the isset() check was failing and I was getting a map in some ocean. IMO I don't think the country check is necessary as I don't imagine a map with only 1 or less piece of data being very useful. Thinking along that line, maybe that's the solution for the second issue, instead of setting address components as the criteria there's just threshold for the number of address components needed to render an address?
I attached a patch basically removing the check for the country.
Comment #5
nigelcunningham commentedI believe this is fixed now. Please reopen and provide more info if that's not the case.
Thanks!
Nigel
Comment #6
nigelcunningham commented