« Telephone Area Code (NPA) Map | Main | Relative Pixel Location Algorithm in Perl »

New demo: Resizable/Movable Ground Overlay

This Google Maps API demo is a modification of Pam's example that adds a few things such as being movable and the image is created on the fly based on the SW and NE corner coordinates.

On the server, the coordinates are transformed into pixels and the image is generated. The image contains the size in pixels and a square to indicate if there is any stretching of the image.

The purpose of this demo is as a starting point for generating an image with POI's, polygons and other information that can substitute for a tile overlay. It's much easier to implement and also can yield real time results if the underlying data is subject to change.

http://maps.huge.info/goverlay.htm

Here's the Perl module that calculates a "relative pixel:" (a modification of Ian Dee's PHP script)

# Calculate Relative Pixel...

To execute:

my @d = &RelPix( <latitude>,<longitude>,<zoom> ) ;

sub RelPix
{
my $lat = shift ;
my $lng = shift ;
my $zoom = shift ;
my $e = 0 ;
my @d = ( ) ; # 0:x 1:y

my $PI = 3.1415926536 ;
my $bc = 2 * $PI;
my $Wa = $PI / 180;
my $cp = 2 ** ($zoom + 8) ;
my $pixLngDeg = $cp / 360;
my $pixLngRad = $cp / $bc ;
my $bmO = $cp / 2 ;

$d[0] = sprintf("%0.0f", $bmO + $lng * $pixLngDeg ) ;

$e = sin($lat * $Wa) ;

if( $e > 0.99999 )
{
$e = 0.99999 ;
}

if( $e < -0.99999 )
{
$e = -0.99999 ;
}

$d[1] = sprintf("%0.0f", $bmO + 0.5 * log((1 + $e) / (1 - $e)) * (-1) * $pixLngRad ) ;

return (@d) ;
}

About

This page contains a single entry from the blog posted on November 23, 2007 10:44 PM.

The previous post in this blog was Telephone Area Code (NPA) Map.

The next post in this blog is Relative Pixel Location Algorithm in Perl.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31