NAME
Geo::GoogleMaps::OffsetCenter - Offset a Lat/Long in Google Maps
VERSION
version 0.03
SYNOPSIS
use Geo::GoogleMaps::OffsetCenter qw/ offset_center_by_occlusion offset_center_by_pixel /;
my $new_lat_long = offset_center_by_occlusion(
52.3728, # latitude
4.8930, # longitude
800, # width
400, # height
16, # Google Maps zoom level
200 # left-bound width of the occlusion
);
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_occlusion
-
- 1. Latitude
-
A valid latitude, basically a floating point number.
- 2. Longitude
-
A valid longitude, same as above.
- 3. Total Width of the Map Area
-
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. Total Height of the Map Area
-
Height is currently ignored, height offset has not been integrated here.
- 6. Google Maps Zoom Level
-
A Google Maps zoom-level, basicaly 0 .. 21.
- 6. Pixels of Occlusion from the 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.
- 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.
LIMITATIONS
Currently, for
offset_center_by_occlusion
, there is no vertical offset. So your lat/long can be transformed along an East-West axis only with this function. If you need an East-West and a North-South transform, seeoffset_center_by_pixel
.For
offset_center_by_occlusion
, it is always assumed to be left-bound.
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.