| 1 | package Geo::Leaflet::TileLayer; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use base qw{Geo::Leaflet::Base}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | our $VERSION = '0.04'; | |||||||||
| 7 | 2 | 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 => '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>', | ||||||||||
| 22 | } | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | This package constructs a Leaflet TileLayer object for use on a L<Geo::Leaflet> 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 | 2 | ▶ | sub osm { | ||||||||
|
Subroutine
osm: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 44 | 2 | my $self = shift; | |||||||||
| 45 | 2 | return $self->new( | |||||||||
| 46 | url => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||||||||||
| 47 | options => { | ||||||||||
| 48 | maxZoom => 19, | ||||||||||
| 49 | attribution => '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>', | ||||||||||
| 50 | }, | ||||||||||
| 51 | @_, | ||||||||||
| 52 | ); | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | =head1 PROPERTIES | ||||||||||
| 56 | |||||||||||
| 57 | =head2 url | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | 1 | ▶ | sub url { | ||||||||
|
Subroutine
url: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||
| 62 | 1 | my $self = shift; | |||||||||
| 63 | 1 | ▶ | $self->{'url'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 1 | ▶ | die("Error: url required") unless $self->{'url'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 1 | return $self->{'url'}; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | =head1 METHODS | ||||||||||
| 69 | |||||||||||
| 70 | =head2 stringify | ||||||||||
| 71 | |||||||||||
| 72 | =cut | ||||||||||
| 73 | |||||||||||
| 74 | 1 | ▶ | sub _method_name {'tileLayer'}; | ||||||||
|
Subroutine
_method_name: called CC=1 SCAR=0.0
| |||||||||||
| 75 | |||||||||||
| 76 | 1 | ▶ | sub stringify { | ||||||||
|
Subroutine
stringify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 77 | 1 | my $self = shift; | |||||||||
| 78 | #L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map); | ||||||||||
| 79 | 1 | 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 | 2 | 1; | |||||||||