| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geo::Leaflet::Base; |
|
2
|
2
|
|
|
2
|
|
16
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
81
|
|
|
3
|
2
|
|
|
2
|
|
25
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
90
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use base qw{Package::New}; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
498
|
|
|
5
|
2
|
|
|
2
|
|
1440
|
use JSON::XS; |
|
|
2
|
|
|
|
|
20320
|
|
|
|
2
|
|
|
|
|
1053
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
|
8
|
|
|
|
|
|
|
our $PACKAGE = __PACKAGE__; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Geo::Leaflet::Base - Leaflet base object |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Geo::Leaflet; |
|
17
|
|
|
|
|
|
|
my $map = Geo::Leaflet->new; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This package provides a base package for L map objects. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 new |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 PROPERTIES |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 options |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub options { |
|
34
|
6
|
|
|
6
|
1
|
11
|
my $self = shift; |
|
35
|
6
|
50
|
|
|
|
26
|
$self->{'options'} = shift if @_; |
|
36
|
6
|
100
|
|
|
|
20
|
$self->{'options'} = {} unless $self->{'options'}; |
|
37
|
6
|
50
|
|
|
|
18
|
die("Error: options must be a hash") unless ref($self->{'options'}) eq 'HASH'; |
|
38
|
6
|
|
|
|
|
71
|
return $self->{'options'}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 METHODS |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 stringify_base |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub stringify_base { |
|
48
|
3
|
|
|
3
|
1
|
5
|
my $self = shift; |
|
49
|
3
|
|
|
|
|
6
|
my $value = shift; |
|
50
|
|
|
|
|
|
|
#const tiles = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { |
|
51
|
|
|
|
|
|
|
# maxZoom: 19, |
|
52
|
|
|
|
|
|
|
# attribution: '© OpenStreetMap' |
|
53
|
|
|
|
|
|
|
# }).addTo(map); |
|
54
|
|
|
|
|
|
|
# |
|
55
|
|
|
|
|
|
|
#const circle = L.circle([51.508, -0.11], { |
|
56
|
|
|
|
|
|
|
# color: 'red', |
|
57
|
|
|
|
|
|
|
# fillColor: '#f03', |
|
58
|
|
|
|
|
|
|
# fillOpacity: 0.5, |
|
59
|
|
|
|
|
|
|
# radius: 500 |
|
60
|
|
|
|
|
|
|
# }).addTo(map); |
|
61
|
3
|
|
|
|
|
9
|
my $class = ref($self); #e.g., Geo::Leaflet::circle |
|
62
|
3
|
|
|
|
|
21
|
$class =~ s/.*:://; #e.g., "circle" |
|
63
|
3
|
|
|
|
|
5
|
my $addmap = '.addTo(map)'; |
|
64
|
3
|
100
|
66
|
|
|
37
|
my $popup = $self->can('popup') && $self->popup ? sprintf('.bindPopup(%s)', $self->JSON->encode($self->popup)) : ''; |
|
65
|
3
|
50
|
66
|
|
|
37
|
my $tooltip = $self->can('tooltip') && $self->tooltip ? sprintf('.bindTooltip(%s)', $self->JSON->encode($self->tooltip)) : ''; |
|
66
|
3
|
|
|
|
|
11
|
return sprintf(q{L.%s(%s, %s)%s%s%s;}, |
|
67
|
|
|
|
|
|
|
$class, |
|
68
|
|
|
|
|
|
|
$self->JSON->encode($value), |
|
69
|
|
|
|
|
|
|
$self->JSON->encode($self->options), |
|
70
|
|
|
|
|
|
|
$addmap, |
|
71
|
|
|
|
|
|
|
$popup, |
|
72
|
|
|
|
|
|
|
$tooltip, |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 JSON |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub JSON { |
|
81
|
10
|
|
|
10
|
1
|
15
|
my $self = shift; |
|
82
|
10
|
|
|
|
|
62
|
$self->{'JSON'} = JSON::XS->new->allow_nonref; |
|
83
|
10
|
|
|
|
|
61
|
return $self->{'JSON'}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 AUTHOR |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Michael R. Davis |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Copyright (C) 2024 by Michael R. Davis |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
MIT LICENSE |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |