Geo-GoogleMaps-OffsetCenter

 view release on metacpan or  search on metacpan

lib/Geo/GoogleMaps/OffsetCenter.pm  view on Meta::CPAN


        # now find the number of degrees we need to move
        $vertical_offset_in_degrees = $meters_offset / $meters_per_degree_vertical;
    }

    $latitude_geo_entity  += $vertical_offset_in_degrees;
    $longitude_geo_entity += $horizontal_offset_in_degrees;

    return {
        latitude  => sprintf( '%.6f', $latitude_geo_entity ),
        longitude => sprintf( '%.6f', $longitude_geo_entity ),
    };
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

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

=head1 VERSION

version 0.04

=head1 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
 );

=head1 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:

=over 4

=item *

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

=item *

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

=back

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.

=head1 NAME

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

=head1 VERSION

 version 0.03

=head1 METHODS

=over 4

=item I<offset_center_by_pixel>

=over 8

=item 1. Latitude

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

=item 2. Longitude

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

=item 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.

=item 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.

=item 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



( run in 3.707 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )