package google_map; use strict; use LWP; sub GetCode { my ($map_key,$lat,$long,$zoom)=@_; my $head = < HEAD my $body= < Your current location is $ENV{REMOTE_ADDR}:
BODY return($head,$body); } sub GetHTMLCode { my ($head,$body)=@_; my $html = < Your current location $head $body HTML return $html; } sub GetCoordinates { my $ip = shift; my ($lat,$long); my $ua = new LWP::UserAgent; $ua->agent("Opera/9.0 " . $ua->agent); $ua->timeout("5"); my $req = new HTTP::Request( GET => "http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=$ip"); my $res = $ua->request($req); if (! $res->is_success) { die "can't get acccess to server \n"; } my $content=$res->content; foreach my $str (split(/\n/,$content)){ $lat = $1 if ($str =~ /meta name=.latitude. content=.(\d+\.\d+)./); $long = $1 if ($str =~ /meta name=.longitude. content=.(\d+\.\d+)./); } return($long,$lat); } 1; __END__