The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

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

VERSION

version 0.01

SYNOPSIS

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

 my $new_lat_long = offset_google_maps_center(
    52.3728, # latitude
    4.8930,  # longitude
    800,     # width
    400,     # height
    16,      # Google Maps zoom level
    200      # left-bound width of the occlusion
 );

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. Maybe your overlay is transparent, maybe it doesn't cover the enclosing map area edge-to-edge, so you need map tiles to be displayed under the occlusion, but you want a point-of-interest (specified by a latitude and a longitude) to be centered on your effective map area, the smaller area to the right.

This module will allow you to do an offset of a given latitude/longitude, given the width of your original box, and the left-bound width of your occlusion.

NAME

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

VERSION

 version 0.01

METHODS

offset_google_maps_center
1. latitude_geo_entity

A valid latitude, basically a floating point number.

2. longitude_geo_entity

A valid longitude, same as above.

3. width_total

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

4. height_total

Height is currently ignored, height offset has not been integrated here.

5. zoom_level

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

See Google Maps Documentation.

6. width_occlusion_from_left

The occluded area must be specified as left-bound, which means the offset is always towards the right. This is a known limitation. This should always be less than the total area of the maps displayed. Otherwise you're just being silly.

LIMITATIONS

  • Currently, occlusions are only to be left-bound

  • There is no latitude offset, your location will now be offset by longitude only, i.e., from the west, heading east

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.

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.