The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Geo::GoogleMaps::OffsetCenter - Offset a Lat/Long in Google Maps

VERSION

version 0.04

SYNOPSIS

 use Geo::GoogleMaps::OffsetCenter qw/ offset_center_by_pixel /;

 my $new_lat_long = offset_center_by_pixel(
    52.3728, # latitude
    4.8930,  # longitude
    800,     # width
    400,     # height
    622,     # desired x-coordinate
    70,      # desired y-coordinate
    16,      # Google Maps zoom level
 );

DESCRIPTION

Consider the following situation:

 A
 +-----------------------------------------------------+
 | +-----------------------+B                          |
 | |                       |                           |
 | |  Lorem ipsum          |                           |
 | |                       |           Map Area        |
 | |                       |                           |
 | |                       |                           |
 | |                       |                           |
 | +-----------------------+                           |
 +-----------------------------------------------------+

Box A is your full map area, and box B is an overlay containing text. Box B is considered the occlusion in this case.

This means the effective map area is the region to the right, even though map tiles need to be rendered below box A. There are many display situations where this might be necessary:

  • The overlay is translucent, and map tiles are visible beneath it.

  • The overlay does not touch the edges of the map it overlays, and so it needs to be framed by map tiles.

This module will allow you to do an offset of a given latitude/longitude under different circumstances.

There are 2 prevailing techniques in this module. By specifying a left-bound occlusion, and by specifying pixel coordinated on your image.

NAME

Geo::GoogleMaps::OffsetCenter - Offset a Lat/Long to account for an occlusion over your map area

VERSION

 version 0.03

METHODS

offset_center_by_pixel
1. Latitude

A valid latitude of your geo entity, basically a floating point number.

2. Longitude

A valid longitude of your geo entity, same as above.

3. Total Width of the Map Area

The total width of the map you want rendered. This includes any occluded areas, although it is partially or wholly occluded, you will need a rendering of a map in this area.

4. Total Height of the Map Area

The total height of the map you want rendered, include possibly occluded areas, same as above. This function allows vertical offset.

5. Desired X Coordinate

Consider your image as a cartesian coordinate space.

   y                                            
   ^                                            
   |                                            
   |                                            
   |                                            
   |                       . (x,y)              
   |                                            
   +--------------------------------------> x   

x represents width, and y represents height. Origined at the bottom-left of your image, this is the x coordinate of where you need your lat/long to be rendered on the image.

6. Desired Y Coordinate

Same as above, except the y coordinate on the image.

7. Google Maps Zoom Level

A Google Maps zoom-level, basically 0 .. 21.

See Google Maps Documentation.

ACKNOWLEDGEMENT

This module was originally developed for use at Booking.com, and was genericized and published on CPAN with their permission, for which the author would like to express his gratitude.

AUTHOR

Iftekharul Haque <iftekhar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Iftekharul Haque.

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