File Coverage

blib/lib/Geo/Leaflet/TileLayer.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod 3 3 100.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Geo::Leaflet::TileLayer;
2 2     2   13 use strict;
  2         3  
  2         66  
3 2     2   9 use warnings;
  2         5  
  2         90  
4 2     2   10 use base qw{Geo::Leaflet::Base};
  2         3  
  2         976  
5              
6             our $VERSION = '0.04';
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 3 my $self = shift;
45 2         36 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 1 my $self = shift;
63 1 50       3 $self->{'url'} = shift if @_;
64 1 50       3 die("Error: url required") unless $self->{'url'};
65 1         7 return $self->{'url'};
66             }
67              
68             =head1 METHODS
69              
70             =head2 stringify
71              
72             =cut
73              
74 1     1   9 sub _method_name {'tileLayer'};
75              
76             sub stringify {
77 1     1 1 2 my $self = shift;
78             #L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© OpenStreetMap contributors'}).addTo(map);
79 1         8 return $self->stringify_base($self->url);
80             }
81              
82             =head1 SEE ALSO
83              
84             =head1 AUTHOR
85              
86             Michael R. Davis
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             Copyright (C) 2024 by Michael R. Davis
91              
92             MIT LICENSE
93              
94             =cut
95              
96             1;