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?

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.

  • Thank you, the "Location Entity (location_entity)" module was not active. It works fine now. – Miquel Correa Casablanca Jan 26 '16 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.