Michael Portnoy > Geo-GoogleMaps-FitBoundsZoomer-1.01 > Geo::GoogleMaps::FitBoundsZoomer

Download:
Geo-GoogleMaps-FitBoundsZoomer-1.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.01   Source   Latest Release: Geo-GoogleMaps-FitBoundsZoomer-1.03

NAME ^

Geo::GoogleMaps::FitBoundsZoomer

SYNOPSIS ^

  use Geo::GoogleMaps::FitBoundsZoomer;

 
  my $zoomer = Geo::GoogleMaps::FitBoundsZoomer::->new();

  my @map_points =  
      ( 
          {'lat' => 43.72,   'long' => -79.42},
          {'lat' => 44.13,   'long' => -79.60},
          {'lat' => 43.87,   'long' => -79.07},
          {'lat' => 43.86,   'long' => -79.72},
          {'lat' => 44.12,   'long' => -79.17},
      );

  my $map_height_pixels = 380;
  my $map_width_pixels  = 400;


  my $zoom = $zoomer->max_bounding_zoom( points => \@map_points,
                                         height => $map_height_pixels,
                                         width  => $map_width_pixels );

  my $center = $zoomer->bounding_box_center();

DESCRIPTION ^

Geo::GoogleMaps::FitBoundsZoomer calculates the maximum Google Maps zoom which fits the minimum bounding rectangle of Google Map points.

It can also return the center coordinates for the bounding rectangle.

METHODS ^

new
  $zoomer = Geo::GoogleMaps::FitBoundsZoomer->new();
  $zoomer = Geo::GoogleMaps::FitBoundsZoomer->new(points => [ { lat => 43.71, long => -79.38 },
                                                              { lat => 44.82, long => -78.42 } ]);

  $zoomer = Geo::GoogleMaps::FitBoundsZoomer->new(width  => 380);
  $zoomer = Geo::GoogleMaps::FitBoundsZoomer->new(height => 400);
  $zoomer = Geo::GoogleMaps::FitBoundsZoomer->new(zoom_limit => 18);

Creating a new zoomer object:

When creating a new zoomer object, you may optionally wish to initialize it with one or more parameters. The following are required parameters as they are needed in order to calculate the maximum zoom:

points is an array ref of one or more points, each of which is a hash ref to a points' lat and long.

width is the width of the map's viewport in pixels.

height is the height of the map's viewport in pixels.

zoom_limit is an optional parameter which redefines the maximum allowable zoom level. Default is 20.

max_bounding_zoom
  $zoom = $zoomer->max_bounding_zoom();

Returns the maximum Google Maps zoom level for a set of points and a given rectangular viewport geometry. These parameters can be specified when creating a "new" zoomer object, or passed directly to this method.

bounding_box_center
  $center = $zoomer->bounding_box_center();

Returns the center coordinates for the bounding box.

Caveat: Can only be called following a call to "max_bounding_zoom".

Returned data structure is similar to the following:

  { lat => 43.71, long => -79.38 }

CONTRIBUTORS ^

Big thanks to Alex Timoshenko.

AUTHOR ^

Copyright 2012, Michael Portnoy <mport@cpan.org>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

https://developers.google.com/maps

syntax highlighting: