| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::Leaflet::marker; |
|
2
|
2
|
|
|
2
|
|
15
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
89
|
|
|
3
|
2
|
|
|
2
|
|
27
|
use warnings; |
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
128
|
|
|
4
|
2
|
|
|
2
|
|
12
|
use base qw{Geo::Leaflet::Objects}; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
1047
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
7
|
|
|
|
|
|
|
our $PACKAGE = __PACKAGE__; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Geo::Leaflet::marker - Leaflet marker object |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Geo::Leaflet; |
|
16
|
|
|
|
|
|
|
my $map = Geo::Leaflet->new; |
|
17
|
|
|
|
|
|
|
my $marker = $map->marker( |
|
18
|
|
|
|
|
|
|
lat => $lat, |
|
19
|
|
|
|
|
|
|
lon => $lon, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This package constructs a Leaflet marker object for use on a L map. |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 PROPERTIES |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 lat |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub lat { |
|
33
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
34
|
1
|
50
|
|
|
|
4
|
$self->{'lat'} = shift if @_; |
|
35
|
1
|
50
|
|
|
|
21
|
die("Error: lat required") unless defined $self->{'lat'}; |
|
36
|
1
|
|
|
|
|
4
|
return $self->{'lat'}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 lon |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub lon { |
|
44
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
45
|
1
|
50
|
|
|
|
2
|
$self->{'lon'} = shift if @_; |
|
46
|
1
|
50
|
|
|
|
25
|
die("Error: lon required") unless defined $self->{'lon'}; |
|
47
|
1
|
|
|
|
|
14
|
return $self->{'lon'}; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 options |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 popup |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 stringify |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub stringify { |
|
61
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
62
|
1
|
|
|
|
|
7
|
my $options = $self->options; |
|
63
|
1
|
|
|
|
|
2
|
my $value = shift; |
|
64
|
|
|
|
|
|
|
#const object6 = L.marker([51.498,-0.09], |
|
65
|
|
|
|
|
|
|
# {"icon":paddle_1}) |
|
66
|
|
|
|
|
|
|
# .addTo(map).bindPopup("marker icon popup").bindTooltip("marker icon tooltip"); |
|
67
|
1
|
|
|
|
|
2
|
my $class = 'marker'; |
|
68
|
1
|
|
|
|
|
3
|
my $addmap = '.addTo(map)'; |
|
69
|
1
|
50
|
|
|
|
37
|
my $popup = $self->popup ? sprintf('.bindPopup(%s)', $self->JSON->encode($self->popup)) : ''; |
|
70
|
1
|
50
|
|
|
|
8
|
my $tooltip = $self->tooltip ? sprintf('.bindTooltip(%s)', $self->JSON->encode($self->tooltip)) : ''; |
|
71
|
1
|
|
|
|
|
19
|
return sprintf(q{L.%s(%s, %s)%s%s%s;}, |
|
72
|
|
|
|
|
|
|
$class, |
|
73
|
|
|
|
|
|
|
$self->JSON->encode([$self->lat, $self->lon]), |
|
74
|
|
|
|
|
|
|
$self->_hash_to_json($self->options), |
|
75
|
|
|
|
|
|
|
$addmap, |
|
76
|
|
|
|
|
|
|
$popup, |
|
77
|
|
|
|
|
|
|
$tooltip, |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#head2 _hash_to_json |
|
82
|
|
|
|
|
|
|
# |
|
83
|
|
|
|
|
|
|
#Custom JSON encoder! Unfortunately, no Perl encoders support function name encoding as needed here for "icon" keys |
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
#cut |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _hash_to_json { |
|
88
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
|
89
|
1
|
|
|
|
|
2
|
my $hash = shift; |
|
90
|
1
|
|
|
|
|
2
|
my $string = ''; |
|
91
|
1
|
|
|
|
|
4
|
foreach my $key (keys %$hash) { |
|
92
|
0
|
|
|
|
|
0
|
my $value = $hash->{$key}; |
|
93
|
0
|
0
|
|
|
|
0
|
if ($key eq "icon") { |
|
94
|
0
|
|
|
|
|
0
|
$string = $string . join(':', $self->JSON->encode($key), $value); #function name encoding is not supported by any perl package! |
|
95
|
|
|
|
|
|
|
} else { |
|
96
|
0
|
|
|
|
|
0
|
$string = $string . join(':', $self->JSON->encode($key), $self->JSON->encode($value)); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
1
|
|
|
|
|
27
|
return "{$string}"; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Michael R. Davis |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright (C) 2024 by Michael R. Davis |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
MIT LICENSE |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |