Add Geo Information to RSS feeds containing nodes with a cck_map field

burgs - April 10, 2008 - 15:54
Project:cck_map
Version:5.x-3.3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

I've been keen to get this module to output some information that i can import into a google map using RSS feeds.

This is the function i've added to the cck_map.module file to add this functionality to feeds created using views. Any comments would be appreciated, or i can submit this as a patch if you're keen? It's makes a few assumptions, and i wasn't keen to use get_object_vars, but...

<?php
function cck_map_nodeapi(&$node, $op, $teaser = FALSE, $page = FALSE){
    if (
$op == 'rss item'){
     
$fields = content_types($node->type);
       
        foreach(
$fields["fields"] as $field){
          if(
$field["type"] == "map_location"){
             
$n = get_object_vars($node);
              if(
$n[$field["field_name"]][0]["lat"] && $n[$field["field_name"]][0]["lon"]){
                  return array(
                  array(
                   
'key' => 'georss:point',
                   
'namespace' => array('georss' => 'xmlns:georss="http://www.georss.org/georss"'),
                   
'value' => $n[$field["field_name"]][0]["lat"]." ".$n[$field["field_name"]][0]["lon"]
                )
              );
          }
          }
        }
  }
  return array();
}   
?>

This produces views that can be added to Google maps super easily.
Info on the georss standards etc

#1

Summit - November 13, 2008 - 20:23

Hi,

Does somebody have looked at this please?
Thanks a lot in advance!
Greetings,
Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.