NAME

Geo::Google::StaticMaps::V2 - Generate Images from Google Static Maps API V2 API

SYNOPSIS

use Geo::Google::StaticMaps::V2;
my $map=Geo::Google::StaticMaps::V2->new;
print $map->url;
print $map->image;
$map->save("filename.png");

DESCRIPTION

The packages generates images from the Google Static Maps API V2 API which can be saved locally for use in accordance with your license with Google.

USAGE

CONSTRUCTORS

new

use Geo::Google::StaticMaps::V2;
my $map=Geo::Google::StaticMaps::V2->new(
                                         width    => 600,
                                         height   => 480,
                                         sensor   => 0,
                                         scale    => 1,
                                         format   => "png8",
                                         type     => "roadmap",
                                         protocol => "http",
                                         server   => "maps.googleapis.com",
                                         script   => "/maps/api/staticmap",
                                        );

Any property can be specified on construction but all have sane defaults and are not required to be set.

marker

Creates a Geo::Google::StaticMaps::V2::Markers object. Adds the object to the internal Markers array. And adds a first location.

$map->marker(location=>"7140 Main Street, Clifton, Virginia 20124");
$map->marker(location=>[38.780676,-77.387105]);
$map->marker(location=>"38.780676,-77.387105);
$map->marker(location=>{lat=>38.780676,lon=>-77.387105});

Example

my $marker1=$map->marker(location=>{lat=>38.780676,lon=>-77.387105}); #isa L<Geo::Google::StaticMaps::V2::Markers>
$marker1->addLocation([38.780513,-77.387128]);                        #second point shares style

my $marker2=$map->marker(location=>{lat=>38.780596,lon=>-77.386837}); #third point different style
$marker2->size("tiny");                                               #third point is now tiny
$marker1->color("blue");                                              #first and second point are now blue

path

Creates a Geo::Google::StaticMaps::V2::Path object. Adds the object to the internal Paths array.

PROPERTIES

center

center (required if markers not present) defines the center of the map, equidistant from all edges of the map. This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. "40.714728,-73.998672") or a string address (e.g. "City Hall, New York, NY") identifying a unique location on the face of the earth.

zoom

zoom (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map. This parameter takes a numerical value corresponding to the zoom level of the region desired.

width

Width part of size parameter.

UOM: pixels

Note: width of image is actually width times scale

height

Height part of size parameter

UOM: pixels

Note: height of image is actually height times scale

sensor

Sets or returns the sensor value true or false setting is Perlish.

$map->sensor(0);       #default
$map->sensor("false"); #Do not do this as "false" is true to Perl

sensor (required) specifies whether the application requesting the static map is using a sensor to determine the user's location. This parameter is required for all static map requests.

scale

scale (optional) affects the number of pixels that are returned. scale=2 returns twice as many pixels as scale=1 while retaining the same coverage area and level of detail (i.e. the contents of the map don't change). This is useful when developing for high-resolution displays, or when generating a map for printing. The default value is 1. Accepted values are 2 and 4 (4 is only available to Maps API for Business customers.) See Scale Values for more information.

$map->scale; #undef (default is 1; not passed), 1, 2, 4

format

format (optional) defines the format of the resulting image. By default, the Static Maps API creates PNG images. There are several possible formats including GIF, JPEG and PNG types. Which format you use depends on how you intend to present the image. JPEG typically provides greater compression, while GIF and PNG provide greater detail. For more information, see Image Formats.

$map->format; #undef (default is png8; not passed on URL), png8, png32, gif, jpg, jpg-baseline

type

maptype (optional) defines the type of map to construct. There are several possible maptype values, including roadmap, satellite, hybrid, and terrain.

$map->type; #undef (default is roadmap; not passed on URL), roadmap, satellite, terrain, hybrid

server

Sets or returns the Google Maps API server

$map->server("maps.googleapis.com");  #default

script

Sets or returns the script for the Google Maps API Static Map

$map->script("/maps/api/staticmap");  #default

protocol

Sets or returns the protocol

$map->protocol("http");  #default
$map->protocol("https"); #https to avoid cross security domain issues in browsers but uses more resources

METHODS

image

Returns the image as a binary scalar.

See: LWP::UserAgent

save

Downloads and saves image

url

my $url=$map->url; #returns a L<URI> object

Google Enterprise Credentials

This settings are simply passed through to URL::Signature::Google::Maps::API.

I recommend storing the credentials in an INI formatted file and leaving these values as undef.

client

Sets and returns the Google Enterprise Client

key

Sets and returns the Google Enterprise Key

channel

Sets and returns the Google Enterprise channel.

BUGS

SUPPORT

AUTHOR

Michael R. Davis
CPAN ID: MRDVT
Satellite Tracking of People, LLC
mdavis@stopllc.com
http://www.stopllc.com/

COPYRIGHT

This program is free software licensed under the...

The General Public License (GPL) Version 2, June 1991

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

Geo::Google::StaticMaps, Geo::Google::MapObject, Net::Flickr::Geo::GoogleMaps, URL::Signature::Google::Maps::API