Hi,
I am trying to add some nodes with geofield programmaticly.

Right now I am trying to add data with:

$node = new stdClass();
...
$node->field_geo = 'LINESTRING (7.82 48.03, 7.828 48.04, 7.835 48.05, 7.8 48.02, 7.82 48.04, 7.81 48.045)';
...
node_save($node);

but I am getting the warning:

Warning: Invalid argument supplied for foreach() in geofield_field_presave() (line 29 of /home/thomas/www/revier-online/sites/all/modules/geofield/geofield.module).

Which arguments do I have to supply?

Thanks
Thomas

Comments

Thomas_M’s picture

Status: Active » Closed (works as designed)

ok,
got it myself

$node = new stdClass();
...
$node->field_geo[$node->language][0]['wkt'] = 'LINESTRING (7.82 48.03, 7.828 48.04, 7.835 48.05, 7.8 48.02, 7.82 48.04, 7.81 48.045)';
$node->field_geo[$node->language][0]['geo_type'] = 'linestring';
...
node_save($node);