Kwebble : Blog

Label: geocode

  • TwitterWhere

    Gepubliceerd op 26 oktober 2007 in Links.

    TwitterWhere, een nieuw hulpmiddel voor Twitter om een RSS feed te maken van alle Twitter posts uit een bepaalde omgeving, bijvoorbeeld Haarlem.

    • geocode
    • rss
  • Putting the geo position in a Wordpress RSS feed

    Gepubliceerd op 2 oktober 2005 in Programming. 3 reacties

    The last few days I’ve been looking at adding geographic information to articles on this website. For WordPress, the software this site is running on, I found the Geo plugin with which you can store geographic coordinates for an article. The plugin adds this information to the page of each article, but not in the RSS feed, so I made a function that does this, though not automatically.

    To use it, start with adding the following function to the Geo plugin. I’m using version 1.0, don’t know if it works in earlier versions:

    /**
     * Returns the tags with geo information for inclusion in RSS 2.0 feeds.
     *
     * Include a call to this function inside the <item> tag to
     * add tags with geo information if available.
     * To keep the feed valid add these namespace declarations to the <rss> tag:
     *    xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
     *    xmlns:icbm="http://postneo.com/icbm"
     *    xmlns:geourl="http://geourl.org/rss/module/"
     */
    function get_the_rss_geotags() {
    	global $wp_query;
    
    	if(!get_settings('use_geo_positions')) return;
    
    	list($lat, $lon) = split(',', get_post_meta($wp_query->post->ID, '_geo_location', true));
    	if ($lat == '' || $lon == '') {
    		if (get_settings('use_default_geourl')){
    			// send the default here
    			$lat = get_settings('default_geourl_lat');
    			$lon = get_settings('default_geourl_lon');
    		}
    	}
    	if ($lat != '' && $lon != '') {
    		echo "<geo :lat>$lat</geo><geo :long>$lon</geo>\n"
    				. "<icbm :latitude>$lat</icbm><icbm :longitude>$lon</icbm>\n"
    				. "<geourl :longitude>$lon</geourl><geourl :latitude>$lat</geourl>\n";
    	}
    }
    

    Now you can add this line to wp-rss2.php, somewhere inside the <item> tag:

    <?php echo get_the_rss_geotags(); ?>
    

    Also remember to add these namespace declarations to the rss tag:

    <rss version=”2.0”
    	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
    	xmlns:icbm="http://postneo.com/icbm"
    	xmlns:geourl="http://geourl.org/rss/module/">
    

    That’s it.

    • geocode
    • php
    • plugin
    • rss
    • wordpress
  • Rubrieken

    • Artikelen
    • Foto's
    • Links
    • Media
    • Overheid
    • Programming
  • Recente Berichten

    • A trim() method for the JavaScript String class
    • Is u iets opgevallen?
    • Tip: use the axis:axis:1.4 Maven artifact if you need Axis 1.4 support
    • Google Closure tools
    • Google en Microsoft indexeren tweets
  • Abonneren

    • Atom feed Artikelen
    • Atom feed Reacties
  • Archief

© Rob Schlüter - Contact