I'm newbie using Geocode, but I'm trying o use it and I can´t geocode anything. When I save a new node, Druapl always return this error:

.
warning: Invalid argument supplied for foreach() in C:\AppServ\www\drupal\sites\all\modules\geocode\modules\geocode_widget\geocode_widget.module on line 71.

$geo_field['widget']['geocode_fields'] is always null.

Thanks!!

Comments

manski2’s picture

Priority: Normal » Critical

Same thing here, followed the instructions in http://www.geojune.org/doc/getting-started-mapping/drupal-mapping-cookbo..., and nothing but this error appears repeatedly.

manski2’s picture

I somehow got the correct fields to show up by adding 'text' to the list that included 'textfield' in (http://drupal.org/node/416506) but it's still not geocoding anything for me.

how / when does that happen?

John

tstoeckler’s picture

Marked #520744: Error in geocode_widget.module as a duplicate.
There I had the same issue as described above.

gagarine’s picture

Title: Geocode doesn´t work » Geocode doesn´t work: other field don't show up

I follow the #2 and change in ligne 64 of geocode.module

  'field types' => array('postal', 'textfield'),

to

  'field types' => array('postal','text'),

And the field show up but "Return value" only have "point" instead of all return type (it's normal?):

     'return types' => array(
      'geo' => array('point'),
      'postal' => array('postal'),
      'text' => array('country', 'city', 'state', 'zip'),
    ),

EDIT: ok return value need to be a point apparently... but anyway nothing is returned and the field stay empty. I don't understand where in the code the geocode should be do.

EDIT2: Ok ok.. my IDE don't refresh all files... in finally found the geocode.inc hum... take a look tomorrow to see what append and why no geocoded value is returned.

sorry time to sleep for me i think.

gagarine’s picture

Title: Geocode doesn´t work: other field don't show up » Geocode doesn´t work: nothing is geocoded from text field
tstoeckler’s picture

Title: Geocode doesn´t work: nothing is geocoded from text field » PHP error in geocode_widget.module

More descriptive title

tauno’s picture

I looked into this a bit based on #4 and it looks like the the format of $values that geocode() is returning is different from the format of the form field. In my testing I'm using a text field with unlimited values as the source for my geocode field (which also allows unlimited values).

To get any return values from geocode() I made this adjustment:
In geocode_widget.module, geocode_widget_form_validate() I changed line 76 from

$input = $form[$field][$delta]['#value'];

to:

$input = $form[$field][$delta]['#value']['value'];

Now $values has the right values, but the format seems wrong for the form_set_value() call
print_r($values):

Array
(
    [0] => Array
        (
            [wkt] => POINT(-123.101276 44.045555)
            [lat] => 44.045555
            [lon] => -123.101276
        )

    [1] => Array
        (
            [wkt] => POINT(-122.670399 45.523875)
            [lat] => 45.523875
            [lon] => -122.670399
        )

    [2] => Array
        (
            [wkt] => POINT(-122.419209 37.775206)
            [lat] => 37.775206
            [lon] => -122.419209
        )

    [field_locations_add_more] => Array
        (
            [wkt] => POINT(-0.7532809 38.4825801)
            [lat] => 38.4825801
            [lon] => -0.7532809
        )

)

(strange that field_locations_add_more was geocoded too...)

and where we're trying to put the values...
print_r($form['geo_field_name']):

Array
(
    [#type] => value
    [#value] => Array
        (
            [0] => Array
                (
                    [srid] => 
                    [wkb] => 
                    [bbox] => 
                    [centroid] => 
                )

        )

    [#required] => 0
    [#columns] => Array
        (
            [0] => geo
        )

    [#title] => Geo
    [#description] => 
    [#delta] => 0
    [#field_name] => field_geo
    [#type_name] => posting
    [#tree] => 1
    [#weight] => 9
    [#access] => 1
    [#count] => 9
    [#post] => Array
    //...other fields below here

So it looks like $values is using wkt, lat, lon and the field actually has srid, wkb, bbox, centroid.

I also just saw a geo issue that may be related: #489818: geo_field fields not storing data

allie micka’s picture

Status: Active » Fixed

I daresay this is fixed in CVS.

Thanks!

gagarine’s picture

Perhaps a stupid question but why the "6.x-1.x-dev" package on the geocode project page is not automatically updated? This is not the same branch? Can you provide a package from the HEAD?

tstoeckler’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.