strStansDonutsXML = $stans->toXML();
# Export a location as JSON data to use with Google Maps
my $strRoscoesJSON = $roscoes->toJSON();
=head1 DESCRIPTION
Geo::Google provides access to the map
mentation.
=item JSON exporting is not exactly identical to the original Google
JSON response. Some of the Google Maps-specific data is discarded
during parsing, and the perl JSON module does not
allow for bare keys
while exporting to a JSON string. It should still be functionally
interchangeable with a Google JSON reponse.
=back
=head1 SEE ALSO
http://maps.google.com
http://www.goog
package Geo::Google::Location;
use strict;
use warnings;
use Data::Dumper;
use URI::Escape;
use JSON;
use Geo::Google;
our $VERSION = '0.04-rc3';
use constant FMT => <<_FMT_;
<location infoStyle="%s"
toJSON {
my $self = shift;
my $json = new JSON (barekey => 1);
# Construct the shell of a new perl data structure that we
# can pass off to the JSON module for rendering to a string
my $preJSON
= Geo::Google::_JSONrenderSkeleton();
# Fill the perl data structure with information from this
# location
$preJSON->{"form"}->{"l"}->{"near"} = $self->title();
$preJSON->{"form"}->{"q"}->{"q"} =
Individual segments are used in Google Maps as
HTML with JavaScript inside a JSON response from the server.
The JSON structure used by Google Maps doesn't actually contain
segments. They are im
toJSON {
my $self = shift;
my $json = new JSON (barekey => 1);
# Construct the shell of a new perl data structure that we
# can pass off to the JSON module for rendering to a string
my $preJSON
= Geo::Google::_JSONrenderSkeleton();
# Fill the perl data structure with information from this
# location
my @locations = $self->locations();
$preJSON->{"form"}->{"l"}->{"near"} =
$location
eJSON->{"form"}->{"q"}->{"q"} = "from:" .
$locations[0]->title();
for (my $i=1; $i<=$#locations; $i++) {
$preJSON->{"form"}->{"q"}->{"q"} .= " to:" .
$locations[$i]->title();
}
$preJSON-