Chapter 9 — Using Overlays 149
information source is an embedded hash structure containing the X, Y, and title information
for each restaurant. The script generates the necessary text when the script is called.
Listing 9-2:Generating a Google Map HTML File from a Script
#!/usr/bin/perl
use CGI qw/:standard/;
print header(-type => ‘text/html’);
my $points = [
{x => -0.6394,
y => 52.9114,
title => ‘China Inn’},
{x => -0.64,
y => 52.909444,
title => ‘One on Wharf’},
{x => -0.64454,
y => 52.91066,
title => ‘Hop Sing’},
{x => -0.642743,
y => 52.9123959,
title => ‘Nicklebys’},
{x => -0.6376,
y => 52.9073,
title => ‘Siam Garden’},
];
page_header();
js_addmarker();
js_movemap();
js_onLoad();
page_footer();
sub page_header
{
print <<EOF;
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<title>MCslp Maps Chapter 9, Ex 2</title>
<script src=”http://maps.google.com/maps?file=api&v=1&key=XXX”
type=”text/javascript”>
</script>
<script type=”text/javascript”>
Continued