File Coverage

blib/lib/Geo/Leaflet/tileLayer.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package Geo::Leaflet::tileLayer;
2 2     2   27 use strict;
  2         3  
  2         79  
3 2     2   8 use warnings;
  2         4  
  2         88  
4 2     2   10 use base qw{Geo::Leaflet::Base};
  2         4  
  2         948  
5              
6             our $VERSION = '0.03';
7             our $PACKAGE = __PACKAGE__;
8              
9             =head1 NAME
10              
11             Geo::Leaflet::tileLayer - Leaflet tileLayer Object
12              
13             =head1 SYNOPSIS
14              
15             use Geo::Leaflet;
16             my $map = Geo::Leaflet->new;
17             my $tileLayer = $map->tileLayer(
18             url => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
19             options => {
20             maxZoom => 19,
21             attribution => '© OpenStreetMap',
22             }
23             );
24              
25             =head1 DESCRIPTION
26              
27             This package constructs a Leaflet tileLayer object for use on a L map.
28              
29             =head1 CONSTRUCTORS
30              
31             =head2 new
32              
33             Returns a tileLayer object
34              
35             =head2 osm
36              
37             Returns the default OpenStreetMaps.org tileLayer.
38              
39             my $tileLayer = Geo::Leaflet::tileLayer->osm;
40              
41             =cut
42              
43             sub osm {
44 2     2 1 4 my $self = shift;
45 2         29 return $self->new(
46             url => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
47             options => {
48             maxZoom => 19,
49             attribution => '© OpenStreetMap',
50             },
51             @_,
52             );
53             }
54              
55             =head1 PROPERTIES
56              
57             =head2 url
58              
59             =cut
60              
61             sub url {
62 1     1 1 2 my $self = shift;
63 1 50       4 $self->{'url'} = shift if @_;
64 1 50       5 die("Error: url required") unless $self->{'url'};
65 1         11 return $self->{'url'};
66             }
67              
68             =head1 METHODS
69              
70             =head2 stringify
71              
72             =cut
73              
74             sub stringify {
75 1     1 1 3 my $self = shift;
76             #L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© OpenStreetMap contributors'}).addTo(map);
77 1         4 return $self->stringify_base($self->url);
78             }
79              
80             =head1 SEE ALSO
81              
82             =head1 AUTHOR
83              
84             Michael R. Davis
85              
86             =head1 COPYRIGHT AND LICENSE
87              
88             Copyright (C) 2024 by Michael R. Davis
89              
90             MIT LICENSE
91              
92             =cut
93              
94             1;