File Coverage

blib/lib/Geo/Google/StaticMaps/V2/Markers.pm
Criterion Covered Total %
statement 42 44 95.4
branch 26 28 92.8
condition 6 12 50.0
subroutine 9 9 100.0
pod 5 5 100.0
total 88 98 89.8


line stmt bran cond sub pod time code
1             package Geo::Google::StaticMaps::V2::Markers;
2 10     10   61 use warnings;
  10         18  
  10         383  
3 10     10   52 use strict;
  10         23  
  10         446  
4 10     10   52 use base qw{Geo::Google::StaticMaps::V2::Visible};
  10         16  
  10         6267  
5             our $VERSION = '0.08';
6             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             sub _styles {
29 20     20   31 my $self=shift;
30 20         32 my @styles=();
31 20 100       53 push @styles, join ":", size => $self->size if defined $self->size;
32 20 100       65 push @styles, join ":", color => $self->color if defined $self->color;
33 20 100       56 push @styles, join ":", label => $self->label if defined $self->label;
34 20 100       74 push @styles, join ":", icon => $self->icon if defined $self->icon;
35 20 50       56 push @styles, join ":", shadow => $self->shadow ? "true" : "false" if defined $self->shadow;
    100          
36 20         71 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             sub size {
46 27     27 1 32 my $self=shift;
47 27 100       76 $self->{"size"}=shift if @_;
48 27         89 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             sub color {
65 41     41 1 68 my $self=shift;
66 41 100       103 $self->{"color"}=shift if @_;
67 41 100       97 if (ref($self->{"color"})) {
68 9         17 my $r;
69             my $g;
70 0         0 my $b;
71 9 100       33 if (ref($self->{"color"}) eq "HASH") {
    50          
72 6   50     33 $r = $self->{"color"}->{"r"} || 0;
73 6   50     22 $g = $self->{"color"}->{"g"} || 0;
74 6   50     17 $b = $self->{"color"}->{"b"} || 0;
75             } elsif (ref($self->{"color"}) eq "ARRAY") {
76 3   50     16 $r = $self->{"color"}->[0] || 0;
77 3   50     14 $g = $self->{"color"}->[1] || 0;
78 3   50     10 $b = $self->{"color"}->[2] || 0;
79             } else {
80 0         0 die("Error: Unknown reference type expecting HASH or ARRAY.");
81             }
82 9         52 return sprintf("0x%02X%02X%02X", $r, $g, $b);
83             } else {
84 32         123 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             sub label {
95 28     28 1 35 my $self=shift;
96 28 100       66 $self->{"label"}=shift if @_;
97 28         85 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             =cut
109              
110             sub icon {
111 26     26 1 35 my $self=shift;
112 26 100       57 $self->{"icon"}=shift if @_;
113 26         79 return $self->{"icon"};
114             }
115              
116             =head2 shadow
117              
118             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.
119              
120             =cut
121              
122             sub shadow {
123 25     25 1 32 my $self=shift;
124 25 100       58 $self->{"shadow"}=shift if @_;
125 25         79 return $self->{"shadow"};
126             }
127              
128             =head1 METHODS
129              
130             =head2 addLocation
131              
132             $marker->addLocation("Clifton, VA");
133              
134             =head1 BUGS
135              
136             Please log on RT and send an email to the author.
137              
138             =head1 SUPPORT
139              
140             DavisNetworks.com supports all Perl applications including this package.
141              
142             =head1 AUTHOR
143              
144             Michael R. Davis
145             CPAN ID: MRDVT
146             Satellite Tracking of People, LLC
147             mdavis@stopllc.com
148             http://www.stopllc.com/
149              
150             =head1 COPYRIGHT
151              
152             This program is free software licensed under the...
153              
154             The General Public License (GPL) Version 2, June 1991
155              
156             The full text of the license can be found in the LICENSE file included with this module.
157              
158             =head1 SEE ALSO
159              
160             L
161              
162             =cut
163              
164             1;