File Coverage

blib/lib/Geo/Leaflet/Polygon.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 26 28 92.8


line stmt bran cond sub pod time code
1             package Geo::Leaflet::Polygon;
2 2     2   16 use strict;
  2         4  
  2         68  
3 2     2   48 use warnings;
  2         4  
  2         95  
4 2     2   11 use base qw{Geo::Leaflet::Objects};
  2         69  
  2         562  
5              
6             our $VERSION = '0.04';
7             our $PACKAGE = __PACKAGE__;
8              
9             =head1 NAME
10              
11             Geo::Leaflet::Polygon - Leaflet polygon object
12              
13             =head1 SYNOPSIS
14              
15             use Geo::Leaflet;
16             my $map = Geo::Leaflet->new;
17             my $polygon = $map->polygon(
18             coordinates => [[$lat, $lon], ...]
19             options => {},
20             );
21              
22             =head1 DESCRIPTION
23              
24             This package constructs a Leaflet polygon object for use on a L map.
25              
26             =head1 PROPERTIES
27              
28             =head2 coordinates
29              
30             =cut
31              
32             sub coordinates {
33 1     1 1 2 my $self = shift;
34 1 50       3 $self->{'coordinates'} = shift if @_;
35 1 50       3 die("Error: coordinates required") unless defined $self->{'coordinates'};
36 1         5 return $self->{'coordinates'};
37             }
38              
39             =head2 options
40              
41             =head2 popup
42              
43             =head1 METHODS
44              
45             =head2 stringify
46              
47             =cut
48              
49 1     1   2 sub _method_name {'polygon'};
50              
51             sub stringify {
52 1     1 1 1 my $self = shift;
53             # const polygon = L.polygon([
54             # [51.509, -0.08],
55             # [51.503, -0.06],
56             # [51.51, -0.047]
57             # ]).addTo(map).bindPopup('I am a polygon.');
58 1         25 return $self->stringify_base($self->coordinates);
59             }
60              
61             =head1 SEE ALSO
62              
63             =head1 AUTHOR
64              
65             Michael R. Davis
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             Copyright (C) 2024 by Michael R. Davis
70              
71             MIT LICENSE
72              
73             =cut
74              
75             1;