| 1 | package Geo::Google::Location; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use URI::Escape; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Geo::Google; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | our $VERSION = '0.04-rc3'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use constant FMT => <<_FMT_; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | <location infoStyle="%s" id="%s"> | ||||||||||
| 12 | <point lat="%s" lng="%s"/> | ||||||||||
| 13 | <icon image="%s" class="local"/> | ||||||||||
| 14 | <info> | ||||||||||
| 15 | <address> | ||||||||||
| 16 | %s | ||||||||||
| 17 | </address> | ||||||||||
| 18 | </info> | ||||||||||
| 19 | </location> | ||||||||||
| 20 | _FMT_ | ||||||||||
| 21 | |||||||||||
| 22 | # $loc->{'latitude'} = $lat; | ||||||||||
| 23 | # $loc->{'longitude'} = $lng; | ||||||||||
| 24 | # $loc->{'lines'} = [@lines]; | ||||||||||
| 25 | # $loc->{'id'} = $id; | ||||||||||
| 26 | # $loc->{'icon'} = $icon; | ||||||||||
| 27 | # $loc->{'infostyle'} = $infoStyle; | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 30 | 0 | my $class = shift; | |||||||||
| 31 | 0 | my %arg = @_; | |||||||||
| 32 | 0 | my $self = bless \%arg, $class; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub icon { return shift->{'icon'} } | ||||||||
|
Subroutine
icon: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 36 | 0 | ▶ | sub id { return shift->{'id'} } | ||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 37 | 0 | ▶ | sub infostyle { return shift->{'infostyle'} } | ||||||||
|
Subroutine
infostyle: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 38 | 0 | ▶ | sub latitude { return shift->{'latitude'} } | ||||||||
|
Subroutine
latitude: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 39 | 0 | ▶ | sub lines { my $self = shift; return $self->{'lines'} ? @{ $self->{'lines'} } : () } | ||||||||
|
Subroutine
lines: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||
| 40 | 0 | ▶ | sub longitude { return shift->{'longitude'} } | ||||||||
|
Subroutine
longitude: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 41 | 0 | ▶ | sub title { return shift->{'title'} } | ||||||||
|
Subroutine
title: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | sub toXML { | ||||||||
|
Subroutine
toXML: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 44 | 0 | my $self = shift; | |||||||||
| 45 | return sprintf( FMT, | ||||||||||
| 46 | $self->infostyle(), | ||||||||||
| 47 | $self->id(), | ||||||||||
| 48 | $self->latitude(), | ||||||||||
| 49 | $self->longitude(), | ||||||||||
| 50 | $self->icon(), | ||||||||||
| 51 | 0 | join('',map {"<line>$_</line>"} $self->lines() ), | |||||||||
| 52 | ); | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 0 | ▶ | sub toJSON { | ||||||||
|
Subroutine
toJSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 56 | 0 | my $self = shift; | |||||||||
| 57 | 0 | my $json = new JSON (barekey => 1); | |||||||||
| 58 | |||||||||||
| 59 | # Construct the shell of a new perl data structure that we | ||||||||||
| 60 | # can pass off to the JSON module for rendering to a string | ||||||||||
| 61 | 0 | my $preJSON = Geo::Google::_JSONrenderSkeleton(); | |||||||||
| 62 | |||||||||||
| 63 | # Fill the perl data structure with information from this | ||||||||||
| 64 | # location | ||||||||||
| 65 | 0 | $preJSON->{"form"}->{"l"}->{"near"} = $self->title(); | |||||||||
| 66 | 0 | $preJSON->{"form"}->{"q"}->{"q"} = $self->title(); | |||||||||
| 67 | 0 | $preJSON->{"form"}->{"d"}->{"daddr"} = $self->title(); | |||||||||
| 68 | 0 | $preJSON->{"form"}->{"selected"} = "q"; | |||||||||
| 69 | 0 | push( @{$preJSON->{"overlays"}->{"markers"}}, { | |||||||||
| 70 | "icon" => "addr", | ||||||||||
| 71 | "laddr" => $self->title(), | ||||||||||
| 72 | "svaddr" => $self->title(), | ||||||||||
| 73 | "lat" => $self->latitude(), | ||||||||||
| 74 | "lng" => $self->longitude(), | ||||||||||
| 75 | "id" => "addr", | ||||||||||
| 76 | "adr" => 1, | ||||||||||
| 77 | "image" => "/mapfiles/arrow.png", | ||||||||||
| 78 | "elms" => [(3, 2, 6)], | ||||||||||
| 79 | "dtlsUrl" => "/maps?v=1&q=" . uri_escape($self->title()) | ||||||||||
| 80 | . "&ie=UTF8&hl=en&latlng=&ei=", | ||||||||||
| 81 | "infoWindow" => { | ||||||||||
| 82 | "basics" => join("<BR />", $self->lines()), | ||||||||||
| 83 | "type" => "html", | ||||||||||
| 84 | "_" => 0 | ||||||||||
| 85 | } | ||||||||||
| 86 | }); | ||||||||||
| 87 | 0 | $preJSON->{"printheader"} = $self->title(); | |||||||||
| 88 | 0 | $preJSON->{"viewport"}->{"span"}->{"lat"} = "0.089989"; | |||||||||
| 89 | 0 | $preJSON->{"viewport"}->{"span"}->{"lng"} = "0.107881"; | |||||||||
| 90 | 0 | $preJSON->{"viewport"}->{"center"}->{"lat"} = $self->latitude(); | |||||||||
| 91 | 0 | $preJSON->{"viewport"}->{"center"}->{"lng"} = $self->longitude(); | |||||||||
| 92 | 0 | $preJSON->{"url"} = "/maps?v=1&q=" . | |||||||||
| 93 | uri_escape($self->title()) . "&ie=UTF8"; | ||||||||||
| 94 | 0 | $preJSON->{"title"} = $self->title(); | |||||||||
| 95 | |||||||||||
| 96 | # Render the data structure to a JSON string and return it | ||||||||||
| 97 | 0 | return $json->objToJson($preJSON); | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 1 | 1; | |||||||||
| 101 | __END__ | ||||||||||