| 1 | package Geo::Leaflet::icon; | ||||||||||
| 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{Package::New}; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use JSON::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | our $VERSION = '0.03'; | |||||||||
| 8 | 2 | our $PACKAGE = __PACKAGE__; | |||||||||
| 9 | |||||||||||
| 10 | =head1 NAME | ||||||||||
| 11 | |||||||||||
| 12 | Geo::Leaflet::icon - Leaflet icon object | ||||||||||
| 13 | |||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||
| 15 | |||||||||||
| 16 | use Geo::Leaflet; | ||||||||||
| 17 | my $map = Geo::Leaflet->new; | ||||||||||
| 18 | |||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||
| 20 | |||||||||||
| 21 | This package constructs a Leaflet icon object for use in a L<Geo::Leaflet::marker> object. | ||||||||||
| 22 | |||||||||||
| 23 | =head1 CONSTRUCTORS | ||||||||||
| 24 | |||||||||||
| 25 | =head2 new | ||||||||||
| 26 | |||||||||||
| 27 | =head1 PROPERTIES | ||||||||||
| 28 | |||||||||||
| 29 | =head2 name | ||||||||||
| 30 | |||||||||||
| 31 | =cut | ||||||||||
| 32 | |||||||||||
| 33 | sub name { | ||||||||||
| 34 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
name: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 35 | 0 | ▶ | $self->{'name'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | ▶ | die("Error: $PACKAGE name required") unless defined $self->{'name'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 0 | ▶ | die("Error: $PACKAGE name invaild variable name") unless $self->{'name'} =~ m/\A[a-z_][a-z0-9_]*\Z/i; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | 0 | return $self->{'name'}; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | =head2 options | ||||||||||
| 42 | |||||||||||
| 43 | =cut | ||||||||||
| 44 | |||||||||||
| 45 | sub options { | ||||||||||
| 46 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
options: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 47 | 0 | ▶ | $self->{'options'} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 0 | ▶ | $self->{'options'} = {} unless $self->{'options'}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | ▶ | die("Error: $PACKAGE options must be a hash") unless ref($self->{'options'}) eq 'HASH'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | return $self->{'options'}; | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | =head1 METHODS | ||||||||||
| 54 | |||||||||||
| 55 | =head2 stringify | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||
| 58 | |||||||||||
| 59 | sub stringify { | ||||||||||
| 60 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 61 | # var icon_name = L.icon({ | ||||||||||
| 62 | # iconUrl: 'my-icon.png', | ||||||||||
| 63 | # iconSize: [38, 95], | ||||||||||
| 64 | # iconAnchor: [22, 94], | ||||||||||
| 65 | # popupAnchor: [-3, -76], | ||||||||||
| 66 | # shadowUrl: 'my-icon-shadow.png', | ||||||||||
| 67 | # shadowSize: [68, 95], | ||||||||||
| 68 | # shadowAnchor: [22, 94] | ||||||||||
| 69 | # }); | ||||||||||
| 70 | 0 | return sprintf(q{L.icon(%s);}, $self->JSON->encode($self->options)); | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | =head2 JSON | ||||||||||
| 74 | |||||||||||
| 75 | =cut | ||||||||||
| 76 | |||||||||||
| 77 | sub JSON { | ||||||||||
| 78 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
JSON: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 79 | 0 | $self->{'JSON'} = JSON::XS->new->allow_nonref; | |||||||||
| 80 | 0 | return $self->{'JSON'}; | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | =head1 SEE ALSO | ||||||||||
| 84 | |||||||||||
| 85 | =head1 AUTHOR | ||||||||||
| 86 | |||||||||||
| 87 | Michael R. Davis | ||||||||||
| 88 | |||||||||||
| 89 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 90 | |||||||||||
| 91 | Copyright (C) 2024 by Michael R. Davis | ||||||||||
| 92 | |||||||||||
| 93 | MIT LICENSE | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||
| 96 | |||||||||||
| 97 | 2 | 1; | |||||||||