| 1 | package Geo::Google::StaticMaps::V2::Visible; | ||||||||||||||
| 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{Package::New}; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 10 | our $VERSION = '0.07'; | |||||||||||||
| 6 | 10 | our $PACKAGE = __PACKAGE__; | |||||||||||||
| 7 | |||||||||||||||
| 8 | =head1 NAME | ||||||||||||||
| 9 | |||||||||||||||
| 10 | Geo::Google::StaticMaps::V2::Visible - 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 $visible=$map->visible(locations=>["Clifton, VA", "Pag, Croatia"]); #isa Geo::Google::StaticMaps::V2::Visible | ||||||||||||||
| 17 | print $map->url, "\n"; | ||||||||||||||
| 18 | |||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 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. | ||||||||||||||
| 22 | |||||||||||||||
| 23 | =head1 USAGE | ||||||||||||||
| 24 | |||||||||||||||
| 25 | use Geo::Google::StaticMaps::V2; | ||||||||||||||
| 26 | my $map=Geo::Google::StaticMaps::V2->new; | ||||||||||||||
| 27 | my $visible=$map->visible(location=>"Clifton, VA"); #isa Geo::Google::StaticMaps::V2::Visible | ||||||||||||||
| 28 | |||||||||||||||
| 29 | =head2 initialize | ||||||||||||||
| 30 | |||||||||||||||
| 31 | Sets all passed in arguments and folds location parameter into the locations array. | ||||||||||||||
| 32 | |||||||||||||||
| 33 | =cut | ||||||||||||||
| 34 | |||||||||||||||
| 35 | sub initialize { | ||||||||||||||
| 36 | 12 | ▶ | my $self=shift; | ||||||||||||
|
Subroutine
initialize: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||
| 37 | 12 | %$self=@_; | |||||||||||||
| 38 | 12 | ▶ | $self->addLocation(delete $self->{"location"}) if exists $self->{"location"}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | =head2 stringify | ||||||||||||||
| 42 | |||||||||||||||
| 43 | Handles various formats for locations seamlessly. | ||||||||||||||
| 44 | |||||||||||||||
| 45 | =cut | ||||||||||||||
| 46 | |||||||||||||||
| 47 | sub stringify { | ||||||||||||||
| 48 | 48 | ▶ | my $self=shift; | ||||||||||||
|
Subroutine
stringify: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 49 | 48 | my @p=(); | |||||||||||||
| 50 | 48 | push @p, $self->_styles; | |||||||||||||
| 51 | 48 | foreach my $location ($self->locations) { | |||||||||||||
| 52 | 139 | my $string=""; | |||||||||||||
| 53 | 139 | ▶ | if (ref($location) eq "HASH") { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 54 | 2 | $string=sprintf("%0.6f,%0.6f", $location->{"lat"}, $location->{"lon"}); | |||||||||||||
| 55 | } elsif (ref($location) eq "ARRAY") { | ||||||||||||||
| 56 | 4 | $string=sprintf("%0.6f,%0.6f", @$location); | |||||||||||||
| 57 | } else { | ||||||||||||||
| 58 | 133 | $string="$location"; #or any object that overloads | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | 139 | push @p, $string; | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | 48 | return join "|", @p; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | =head2 locations | ||||||||||||||
| 66 | |||||||||||||||
| 67 | Returns the locations array which can be set upon construction. | ||||||||||||||
| 68 | |||||||||||||||
| 69 | =cut | ||||||||||||||
| 70 | |||||||||||||||
| 71 | sub locations { | ||||||||||||||
| 72 | 62 | ▶ | my $self=shift; | ||||||||||||
|
Subroutine
locations: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 73 | 62 | ▶ | $self->{"locations"}=[] unless ref($self->{"locations"}) eq "ARRAY"; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 74 | 62 | ▶ | return wantarray ? @{$self->{"locations"}} : $self->{"locations"}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 75 | } | ||||||||||||||
| 76 | |||||||||||||||
| 77 | sub _styles { | ||||||||||||||
| 78 | 6 | ▶ | my $self=shift; | ||||||||||||
|
Subroutine
_styles: called CC=1 SCAR=0.0
| |||||||||||||||
| 79 | 6 | my @styles=(); | |||||||||||||
| 80 | 6 | return @styles; | |||||||||||||
| 81 | } | ||||||||||||||
| 82 | |||||||||||||||
| 83 | =head1 METHODS | ||||||||||||||
| 84 | |||||||||||||||
| 85 | =head2 addLocation | ||||||||||||||
| 86 | |||||||||||||||
| 87 | $marker->addLocation("Clifton, VA"); | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =cut | ||||||||||||||
| 90 | |||||||||||||||
| 91 | sub addLocation { | ||||||||||||||
| 92 | 14 | ▶ | my $self=shift; | ||||||||||||
|
Subroutine
addLocation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 93 | 14 | push @{$self->locations}, @_; | |||||||||||||
| 94 | 14 | return $self; | |||||||||||||
| 95 | } | ||||||||||||||
| 96 | |||||||||||||||
| 97 | =head1 BUGS | ||||||||||||||
| 98 | |||||||||||||||
| 99 | Please log on RT and send an email to the author. | ||||||||||||||
| 100 | |||||||||||||||
| 101 | =head1 SUPPORT | ||||||||||||||
| 102 | |||||||||||||||
| 103 | DavisNetworks.com supports all Perl applications including this package. | ||||||||||||||
| 104 | |||||||||||||||
| 105 | =head1 AUTHOR | ||||||||||||||
| 106 | |||||||||||||||
| 107 | Michael R. Davis | ||||||||||||||
| 108 | CPAN ID: MRDVT | ||||||||||||||
| 109 | Satellite Tracking of People, LLC | ||||||||||||||
| 110 | mdavis@stopllc.com | ||||||||||||||
| 111 | http://www.stopllc.com/ | ||||||||||||||
| 112 | |||||||||||||||
| 113 | =head1 COPYRIGHT | ||||||||||||||
| 114 | |||||||||||||||
| 115 | This program is free software licensed under the... | ||||||||||||||
| 116 | |||||||||||||||
| 117 | The General Public License (GPL) Version 2, June 1991 | ||||||||||||||
| 118 | |||||||||||||||
| 119 | The full text of the license can be found in the LICENSE file included with this module. | ||||||||||||||
| 120 | |||||||||||||||
| 121 | =head1 SEE ALSO | ||||||||||||||
| 122 | |||||||||||||||
| 123 | L<Geo::Google::StaticMaps::V2>, L<Geo::Google::StaticMaps::V2::Path>, L<Geo::Google::StaticMaps::V2::Markers> | ||||||||||||||
| 124 | |||||||||||||||
| 125 | =cut | ||||||||||||||
| 126 | |||||||||||||||
| 127 | 10 | 1; | |||||||||||||