1

I'm trying to programmatically create a node with a location field, but I'm not able to do it. I have done it in a similar project and it works fine. I use the Entity API module to create the nodes, with this code.

 $localizationmap = array( 'latitude' => $item['field_mapa']['latitude'], 'longitude' => $item['field_mapa']['longitude'], //other elements added here (province, postal_code, country [es, en,...],additional, ...) ); $entity->field_mapa->set($localizationmap); 

I checked the values that are given to the array and they're OK. Drupal log contains the following error:

EntityMetadataWrapperException: Unknown data property field_mapa. en EntityStructureWrapper->getPropertyInfo() (línea 335 de /var/www/vhosts/drupal/litoral.interdigital.biz/sites/all/modules/entity/includes/entity.wrapper.inc).

field_mapa exists and it is the name of the location field I'm trying to fill.

What am I doing wrong?

1 Answer 1

2

It's simply because the stable version of the Location module doesn't support Entity API.

There's a patch here that claims to provide the missing support, obviously use with caution on a dev version of the site first.

1
  • Thank you, the "Location Entity (location_entity)" module was not active. It works fine now. Commented Jan 26, 2016 at 10:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.