V2/Markers.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 92.8% 26 / 28 Conditioncond 50.0% 6 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 85.9% 92 / 107 CC 21 SCAR 19.6
CC
21
Cov
90%
color
12.4
_styles
7.0
size
2.0
CRAP 7.1
« V2/Path.pm ↑ Summary V2.pm »
1 package Geo::Google::StaticMaps::V2::Markers;
2 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use base qw{Geo::Google::StaticMaps::V2::Visible};
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 our $VERSION = '0.12';
6 10 our $PACKAGE = __PACKAGE__;
7  
8 =head1 NAME
9  
10 Geo::Google::StaticMaps::V2::Markers - Generate Images from Google Static Maps V2 API
11  
12 =head1 SYNOPSIS
13  
14 use Geo::Google::StaticMaps::V2;
15 my $map=Geo::Google::StaticMaps::V2->new;
16 my $marker=$map->marker(location=>[$lat=>$lon]); #isa Geo::Google::StaticMaps::V2::Markers
17  
18 =head1 DESCRIPTION
19  
20 The packages generates images from the Google Static Maps V2 API which can be saved locally for use in accordance with your license with Google.
21  
22 =head1 USAGE
23  
24 =head1 PROPERTIES
25  
26 =cut
27  
28 18 ▶sub _styles {
Subroutine _styles: called CC=7 SCAR=19.5
29 18 my $self=shift;
30 18 my @styles=();
31 18 ▶ push @styles, join ":", size => $self->size if defined $self->size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->size 6 12 18
32 18 ▶ push @styles, join ":", color => $self->color if defined $self->color;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->color 15 3 18
33 18 ▶ push @styles, join ":", label => $self->label if defined $self->label;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->label 7 11 18
34 18 ▶ push @styles, join ":", icon => $self->icon if defined $self->icon;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->icon 5 13 18
35 18 ▶ push @styles, join ":", shadow => $self->shadow ? "true" : "false" if defined $self->shadow;
Branch: 2 branches
BranchTrueFalseTotal
if defined $self->shadow 4 14 18
$self->shadow ? : 0 4 4
36 18 return @styles;
37 }
38  
39 =head2 size
40  
41 size: (optional) specifies the size of marker from the set {tiny, mid, small}. If no size parameter is set, the marker will appear in its default (normal) size.
42  
43 =cut
44  
45 25 ▶sub size {
Subroutine size: called CC=2 SCAR=6.9
Pod documented
46 25 my $self=shift;
47 25 ▶ $self->{"size"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 24 25
48 25 return $self->{"size"};
49 }
50  
51 =head2 color
52  
53 Set and returns a formatted marker color code.
54  
55 color: (optional) specifies a 24-bit color (example: color=0xFFFFCC) or a predefined color from the set {black, brown, green, purple, yellow, blue, gray, orange, red, white}.
56  
57 my $color=$marker->color("blue");
58 my $color=$marker->color("0xFFFFCC");
59 my $color=$marker->color({r=>255,g=>0,b=>0}); #maps to red
60 my $color=$marker->color([255,0,0]); #maps to red
61  
62 =cut
63  
64 39 ▶sub color {
Subroutine color: called CC=11 SCAR=25.2
Pod documented
65 39 my $self=shift;
66 39 ▶ $self->{"color"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 6 33 39
67 39 ▶ if (ref($self->{"color"})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'color'}) { } 9 30 39
68 9 my $r;
69 my $g;
70 9 my $b;
71 9 ▶ if (ref($self->{"color"}) eq "HASH") {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->{'color'} eq 'HASH') { } 6 3 9
elsif (ref $self->{'color'} eq 'ARRAY') { } 3 0 3
72 6 ▶ $r = $self->{"color"}->{"r"} || 0;
Condition50%1/2
$self->{'color'}{'r'} || 0
l!l
06
MC/DC0%0/1
$self->{'color'}{'r'} || 0
$self->{'color'}{'r'}
Truth table50%1/2
A
A= $self->{'color'}{'r'}
Aresult
11
00
73 6 ▶ $g = $self->{"color"}->{"g"} || 0;
Condition50%1/2
$self->{'color'}{'g'} || 0
l!l
06
MC/DC0%0/1
$self->{'color'}{'g'} || 0
$self->{'color'}{'g'}
Truth table50%1/2
A
A= $self->{'color'}{'g'}
Aresult
11
00
74 6 ▶ $b = $self->{"color"}->{"b"} || 0;
Condition50%1/2
$self->{'color'}{'b'} || 0
l!l
60
MC/DC0%0/1
$self->{'color'}{'b'} || 0
$self->{'color'}{'b'}
Truth table50%1/2
A
A= $self->{'color'}{'b'}
Aresult
11
00
75 } elsif (ref($self->{"color"}) eq "ARRAY") {
76 3 ▶ $r = $self->{"color"}->[0] || 0;
Condition50%1/2
$self->{'color'}[0] || 0
l!l
03
MC/DC0%0/1
$self->{'color'}[0] || 0
$self->{'color'}[0]
Truth table50%1/2
A
A= $self->{'color'}[0]
Aresult
11
00
77 3 ▶ $g = $self->{"color"}->[1] || 0;
Condition50%1/2
$self->{'color'}[1] || 0
l!l
03
MC/DC0%0/1
$self->{'color'}[1] || 0
$self->{'color'}[1]
Truth table50%1/2
A
A= $self->{'color'}[1]
Aresult
11
00
78 3 ▶ $b = $self->{"color"}->[2] || 0;
Condition50%1/2
$self->{'color'}[2] || 0
l!l
30
MC/DC0%0/1
$self->{'color'}[2] || 0
$self->{'color'}[2]
Truth table50%1/2
A
A= $self->{'color'}[2]
Aresult
11
00
79 } else {
80 0 die("Error: Unknown reference type expecting HASH or ARRAY.");
81 }
82 9 return sprintf("0x%02X%02X%02X", $r, $g, $b);
83 } else {
84 30 return $self->{"color"};
85 }
86 }
87  
88 =head2 label
89  
90 label: (optional) specifies a single uppercase alphanumeric character from the set {A-Z, 0-9}. (The requirement for uppercase characters is new to this version of the API.) Note that default and mid sized markers are the only markers capable of displaying an alphanumeric-character parameter. tiny and small markers are not capable of displaying an alphanumeric-character.
91  
92 =cut
93  
94 26 ▶sub label {
Subroutine label: called CC=2 SCAR=6.9
Pod documented
95 26 my $self=shift;
96 26 ▶ $self->{"label"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 25 26
97 26 return $self->{"label"};
98 }
99  
100 =head2 icon
101  
102 icon specifies a URL to use as the marker's custom icon. Images may be in PNG, JPEG or GIF formats, though PNG is recommended.
103  
104 The icon parameter must be specified using a URL (which should be URL-encoded). You may use any valid URL of your choosing, or a URL-shortening service such as http://goo.gl. Most URL-shortening services have the advantage of automatically encoding URLs. Icons are limited to sizes of 4096 pixels (64x64 for square images), and the Static Maps service allows up to five unique custom icons per request. Note that each of these unique icons may be used multiple times within the static map.
105  
106 Custom icons that have a shadow:true descriptor (the default) will have their "anchor point" set as the bottom center of the provided icon image, from which the shadow is cast. Icons without a shadow (setting a shadow:false descriptor) are instead assumed to be icons centered on their specified locations, so their anchor points are set as the center of the image.
107  
108 Note: As of March 2014, the API does not support HTTPS only HTTP icons
109  
110 =cut
111  
112 24 ▶sub icon {
Subroutine icon: called CC=2 SCAR=6.9
Pod documented
113 24 my $self=shift;
114 24 ▶ $self->{"icon"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 23 24
115 24 return $self->{"icon"};
116 }
117  
118 =head2 shadow
119  
120 shadow (default true) indicates that the Static Maps service should construct an appropriate shadow for the image. This shadow is based on the image's visible region and its opacity/transparency.
121  
122 =cut
123  
124 23 ▶sub shadow {
Subroutine shadow: called CC=2 SCAR=6.9
Pod documented
125 23 my $self=shift;
126 23 ▶ $self->{"shadow"}=shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 1 22 23
127 23 return $self->{"shadow"};
128 }
129  
130 =head1 METHODS
131  
132 =head2 addLocation
133  
134 $marker->addLocation("Clifton, VA");
135 $marker->addLocation({lat=>38.7802903, lon=>-77.3867659});
136 $marker->addLocation([38.7802903, -77.3867659]);
137  
138 =head1 BUGS
139  
140 Please log on RT and send an email to the author.
141  
142 =head1 SUPPORT
143  
144 DavisNetworks.com supports all Perl applications including this package.
145  
146 =head1 AUTHOR
147  
148 Michael R. Davis
149 CPAN ID: MRDVT
150 Satellite Tracking of People, LLC
151 mdavis@stopllc.com
152 http://www.stopllc.com/
153  
154 =head1 COPYRIGHT
155  
156 This program is free software licensed under the...
157  
158 The General Public License (GPL) Version 2, June 1991
159  
160 The full text of the license can be found in the LICENSE file included with this module.
161  
162 =head1 SEE ALSO
163  
164 L<Geo::Google::StaticMaps::V2>
165  
166 =cut
167  
168 10 1;
« V2/Path.pm ↑ Summary V2.pm »