package EPrints::Plugin::Export::TweetStream::GoogleMap; use EPrints::Plugin::Export; @ISA = ( "EPrints::Plugin::Export" ); use strict; sub new { my( $class, %opts ) = @_; my( $self ) = $class->SUPER::new( %opts ); my $n = $self->repository->config('tweepository_newest_coordinates_n'); $n = 'ERR' unless $n; $self->{name} = "Google Map (most recent $n geolocations)"; $self->{accept} = [ 'dataobj/tweetstream' ]; $self->{visible} = "all"; $self->{suffix} = ".html"; $self->{mimetype} = "text/html"; return $self; } sub output_dataobj { my( $plugin, $dataobj, %opts ) = @_; my $repo = $dataobj->repository; my $title = $dataobj->value('title') . ' Most Recent Geolocated Tweets'; my $coordinates = $dataobj->value('newest_coordinates'); my $c = []; foreach my $coordinate (@{$coordinates}) { push @{$c}, join('', '{ lat: ', $coordinate->{lat}, ', lng: ', $coordinate->{lon}, '}'); } my $r; if ($coordinates && scalar @{$coordinates}) { $r = $plugin->_page($title, join(', ',@{$c})); } else { $r = $plugin->_page_empty($title); } if( defined $opts{fh} ) { print {$opts{fh}} $r; return; } return $r; } sub _page_empty { my ($self, $title) = @_; return < $title

Sorry, this tweetstream has no geolocation data at this time. Please check back later.

END } sub _page { my ($self, $title, $coordinate_string) = @_; return < $title
END } 1;