Geo-Heatmap

 view release on metacpan or  search on metacpan

lib/Geo/Heatmap.pm  view on Meta::CPAN

for a real life example see 

http://www.trust-box.at/dev/gm/GoogleMapsHeatmap/www/GoogleMapsHeatmap.html

for Dokumentation see

=head1 HOMEPAGE

http://www.trust-box.at/googlemaps-geoheatmap/

=head1 REQUIRES

  Moose
  CHI
  Imager

=head1 METHODS

=head2 tile

  tile();

  return the tile image in png format

=head1 ATTRIBUTES

  debug
  cache
  logfile
  return_points
  zoom_scale
  palette

=head2 USAGE

Create a Heatmap layer for GoogleMaps

=head3 The HTML part

=begin html

<pre>
<code>
  &lt;head&gt;
     &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt;
     &lt;style type="text/css"&gt;
       html { height: 100% }
       body { height: 100%; margin: 0; padding: 0 }
       #map-canvas { height: 100% }
     &lt;/style&gt;
     &lt;script type="text/javascript"
       src="https://maps.googleapis.com/maps/api/js?key=<yourapikey>&sensor=true"&gt;
     &lt;/script&gt;
     &lt;script type="text/javascript"&gt;
       var overlayMaps = [{
         getTileUrl: function(coord, zoom) {
           return "hm.fcgi?tile="+coord.x+"+"+coord.y+"+"+zoom;
         },
 
         tileSize: new google.maps.Size(256, 256),
         isPng: true,
         opacity: 0.4
       }];
 
       function initialize() {
         var mapOptions = {
           center: new google.maps.LatLng(48.2130, 16.375),
           zoom: 9
         };
         var map = new google.maps.Map(document.getElementById("map-canvas"),
             mapOptions);
 
       var overlayMap = new google.maps.ImageMapType(overlayMaps[0]);
       map.overlayMapTypes.setAt(0,overlayMap);
 
       }
       google.maps.event.addDomListener(window, 'load', initialize);
 
     &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;div id="map-canvas"/&gt;
  &lt;/body&gt;
</code>
</pre>
<br>

=end html

=head3 The (f)cgi part

=begin html

<pre>
<code>
  #!/usr/bin/env perl
  
  use strict;
  use FCGI;
  use DBI;
  use CHI;
  use FindBin qw/$Bin/;
  use lib "$Bin/../lib";
  
  use Geo::Heatmap;
  
  #my $cache = CHI->new( driver  => 'Memcached::libmemcached',
  #    servers    => [ "127.0.0.1:11211" ],
  #    namespace  => 'GoogleMapsHeatmap',
  #);
  
  
  my $cache = CHI->new( driver => 'File',
           root_dir => '/tmp/GoogleMapsHeatmap'
       );
  
  
  our $dbh = DBI->connect("dbi:Pg:dbname=gisdb", 'gisdb', 'gisdb', {AutoCommit => 0});
  
  my $request = FCGI::Request();
  



( run in 2.487 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )