line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geo::Google::Location; |
2
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
5
|
1
|
|
|
1
|
|
5
|
use URI::Escape; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
52
|
|
6
|
1
|
|
|
1
|
|
4
|
use JSON; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
124
|
use Geo::Google; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
62
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.04-rc3'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use constant FMT => <<_FMT_; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
725
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
%s |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub new { |
30
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my %arg = @_; |
32
|
0
|
|
|
|
|
|
my $self = bless \%arg, $class; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
0
|
0
|
|
sub icon { return shift->{'icon'} } |
36
|
0
|
|
|
0
|
0
|
|
sub id { return shift->{'id'} } |
37
|
0
|
|
|
0
|
0
|
|
sub infostyle { return shift->{'infostyle'} } |
38
|
0
|
|
|
0
|
0
|
|
sub latitude { return shift->{'latitude'} } |
39
|
0
|
0
|
|
0
|
0
|
|
sub lines { my $self = shift; return $self->{'lines'} ? @{ $self->{'lines'} } : () } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
0
|
0
|
|
sub longitude { return shift->{'longitude'} } |
41
|
0
|
|
|
0
|
0
|
|
sub title { return shift->{'title'} } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub toXML { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
|
|
|
|
|
return sprintf( FMT, |
46
|
|
|
|
|
|
|
$self->infostyle(), |
47
|
|
|
|
|
|
|
$self->id(), |
48
|
|
|
|
|
|
|
$self->latitude(), |
49
|
|
|
|
|
|
|
$self->longitude(), |
50
|
|
|
|
|
|
|
$self->icon(), |
51
|
0
|
|
|
|
|
|
join('',map {"$_"} $self->lines() ), |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub toJSON { |
56
|
0
|
|
|
0
|
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"}}, { |
|
0
|
|
|
|
|
|
|
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(" ", $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; |
101
|
|
|
|
|
|
|
__END__ |