Closed (fixed)
Project:
Geocoder
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Jul 2011 at 18:30 UTC
Updated:
24 Mar 2012 at 05:33 UTC
Hi,
I try to geocode the user adress from an Adress field cck and there're no data output follow up the geocoding.
How can I solve that issue?
Thanks in advance,
Comments
Comment #1
Loikkk commentedNo one have this bug?
Comment #2
tvilms commentedI'm having this bug too. It's really really frustrating, and I can't seem to get to the bottom of it. I get two types of errors, depending on how I'm configuring the content type fields:
Error #1: Trying to get property of non-object in GoogleGeocode->read() (line 51 of /public_html/sites/all/libraries/geoPHP/lib/adapters/GoogleGeocode.class.php).
Error #2: Warning: Invalid argument supplied for foreach() in geocode_widget_validate_walkthrough() (line 287 of /public_html/sites/all/modules/geocode/geocode.module)
Error 1 seems to be related to Geofield when it tries to geocode the address. Error 2 is then something in the geocode module itself. I had this all working a few module updates back, but now it's not geocoding. I suspect there may be something in Address Field that's leading to Error #1, which I see most of the time.
Comment #3
idmacdonald commentedThe module uses
$this->result = json_decode(@file_get_contents($url));(line 49 of GoogleGeocode.class.php) to actually send the request to Google and get the response. However, the file_get_contents operation will only work if 'allow_url_fopen' is on in the PHP configuration. If 'allow_url_fopen' is not allowed, then the 'file_get_contents' will not be allowed to execute, but the '@' sign suppresses error reporting. A lot of hosting providers rightly consider allow_url_fopen to be a security risk, so it's not really ideal. But this is in the geoPHP library, so I guess an issue should be filed with that project rather than here on Drupal.org.In any case, in the Apache configuration, I added this line, which made the thing work:
php_admin_flag allow_url_fopen onDrupal uses 'drupal_http_request()' these days for those sorts of operations. It would be good if the geoPHP library could use something similar instead of 'allow_url_fopen'.
-Ian
Comment #4
idmacdonald commentedComment #5
hutch commentedPersonally I think the geoPHP library is overkill, something like this works (from a helper module I use on one of my sites):
They work with allow_url_fopen Off, 'drupal_http_request()' uses 'stream_socket_client()'
Seems a better way to do it.
Comment #6
Brandonian commentedTwo things:
1. From the Drupal module perspective, this is an issue with Geocoder, not Geofield. This functionality isn't called from anywhere in Geofield proper. It's up to the maintainers of Geocoder to address if/how to tackle this problem on the module level. IMHO, hutch's code at a glance looks like it could work either as a fallback or as the primary geocoding engine, but would basically amount to duplicating effort between the library and the module.
2. Since the issue is really with the library, the issue needs to be taken up there. I've opened up an issue there for discussion. https://github.com/phayes/geoPHP/issues/6
Comment #7
phayes commentedInteresting that drupal_http_request is allowed but fopen is not!
I would fully support not using geoPHP for geocoding purposes. I think hutch's approach makes a lot of sense. It also helps resolve the issue we were having with additional metadata that geoPHP doesn't return.
Comment #8
phayes commentedThis has been fixed. We're now using a hand-rolled google-geocoder.
This is better anyway as it will let us to address this request: #1295262: Accuracy from google geocode
Comment #10
ahmedhanyfawzy commented#5 is working , very good solution since the location and gmap still under development and their patches are useless in doing reverse geocoding.
Thanks hutch you made my day :)