Hi there! I'm trying to build a gmap with elements from a flickr feed with geodata.

Using the simplepie parser, I was able to pull out the information on longitude and latitude. The problem is that I would like to map those into the Location module longitude and latitude "fields".

Since they are not proper ckk fields (At least that's my understanding), i was unable to make it work.

I suppose i should be writing a mapper, but i don't really have any clue on how to do it.

Any pointers and ideas?

thanks!

MArio

Comments

alex_b’s picture

Have a look at how the taxonomy mapper works (/mappers directory in feedapi_mapper). You should be able to model your mapper after it.

summit’s picture

Subscribing. Greetings, Martijn

geodaniel’s picture

Version: 5.x-1.0-beta6 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.68 KB

Attaching a new .inc file that maps location information from FeedAPI (dependent upon #228111: Add enclosure (and location) support to FeedAPI Drupal 6) to location module.

geodaniel’s picture

StatusFileSize
new1.7 KB

I've fixed up a couple of comments, and now return FALSE if there are no fields, as per the instructions.

Arto’s picture

Status: Needs review » Reviewed & tested by the community

Dan's patch works for me.

Arto’s picture

Title: feed element mapper for location module? » Support for the Location module
Arto’s picture

StatusFileSize
new1.75 KB

This version modifies Dan's patch slightly to add a guard clause preventing a warning: Invalid argument supplied for foreach() PHP warning being issued in circumstances when $feed_element is NULL due to the feed item's latitude/longitude properties being present but empty.

summit’s picture

Hi, not wanting to hijyack this thread, but looking for a Drupal 5 solution on this. I set my own thread about this on duplicate, because I think the location-way is the way to go for hierarchical regional info out of the feed.

I have feedapi working, location working, and the feedapi_taxonomy mapper working.
Next to this I installed the place module to get the location-taxonomy integration (www.drupal.org/project/place).

What I miss on my drupal 5 solution is the location_mapper to map the locations in my feeds to the locations, than hopefully I can place them hierarchical in taxonomy through the place_taxonomy module.

Because the place module is not on Drupal 6, and this the only module is I know of which makes the connection between location and taxonomy I need a drupal 5 solution and I think other peoples on drupal 5 would love a location mapper also!
I would very much like the location mapper into underneath feedapi_mapper list:

Description of available mappers
Only mappers for existing fields on feed items show up.

taxonomy (taxonomy module)
Maps a string or an array of strings to taxonomy terms. Chose a vocabulary from sub options.

Any possibility in getting a drupal5 feedapi_location mapper? Is there planning to backport http://drupal.org/node/228111 (#228111: Add enclosure (and location) support to FeedAPI Drupal 6) to Drupal 5?

EDIT: made a specific issue on location_mapper for drupal 5: http://drupal.org/node/333519

Thanks a lot in advance for considering this and I am willing to test this for you!
Greetings,
Martijn

geodaniel’s picture

Alex, the dependent patch is now included in FeedAPI, so this (Arto's modified version) should be good to go in.

summit’s picture

Hi,

The patch worked for me also on Drupal 5. The missing part was that I also needed to enable location info on the feed-item nodes on which the feed is mapped to.

Please also add country, province, city, street and postal_code to the patch, will this work?

 else if ($op == 'list') {
      $sub_fields['country'] = 'country';
      $sub_fields['province'] = 'province';
      $sub_fields['city'] = 'city';
      $sub_fields['street'] = 'street';
      $sub_fields['postal_code'] = 'postal_code';
      $sub_fields['latitude'] = 'Latitude';
      $sub_fields['longitude'] = 'Longitude';
      return $sub_fields;

See: http://drupal.org/node/333519 for my first tests on this, I do not get the country field in the location table filled through mapping..
Greetings,
Martijn

alex_b’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thanks geodaniel, Arto and others for patching and testing.

@Summit. I take it the D5 issue moved to #333519: Feedapi_mapper_location country, province, city, street and postal_code fields.

Changing status to fixed.

summit’s picture

Hi Arto and Geodaniel,

Is in your install the mapped information also placed in the location table?
In my install this is not the case (on drupal 5).
Just to make sure it is a mistake on drupal 5, or on my site..

EDIT: I think I also have to alter this peace of code to get country etc..inserted:
http://drupal.org/node/333519#comment-1112424

Any feedback appreciated.

greetings,
Martijn

alex_b’s picture

Status: Fixed » Closed (fixed)

Rolled out in beta3. Thanks everybody.