heatmapapi.com Create your own heat maps using HeatMapAPI. Integrate heat map images into Google Maps or other GIS systems. Heat maps are rendered real-time.

API Documentation

Quick Start (Small Datasets < 100 points)

Step 1 Get your FREE API key.
Step 2 Verify that your google map works.
Step 3 Add two javascript files to your page, they are:

<script type="text/javascript" src="http://www.heatmapapi.com/Javascript/HeatmapAPIGoogle3.js"></script>
<script type="text/javascript" src="http://www.heatmapapi.com/Javascript/HeatMapAPI3.aspx?k=YOUR KEY FROM STEP 2"></script>
(note: where it says (YOUR KEY FROM STEP 2) above you put the key you received)
You'll also need to link in jQuery:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
Step 4 In javascript on your page, add the following script:

<script type="text/javascript">
var myHeatmap = new GEOHeatmap();
var myData = null;
$(function() {
// create data
myData = new Array();
for (p = 0; p < 50; p++) {
 var rLatD = Math.floor(Math.random() * 1000);
 var rLonD = Math.floor(Math.random() * 1000);
 var rValD = Math.floor(Math.random() * 10);

 myData.push(38.47 + (rLatD / 15000));
 myData.push(-121.84 + (rLonD / 15000));

// configure HeatMapAPI
myHeatmap.Init(400, 300); // set at pixels for your map
myHeatmap.SetDecay(0); // see documentation

// set up Google map, pass in the heatmap function
var myLatlng = new google.maps.LatLng(38.5, -121.8);
var myOptions = {
 zoom: 11,
 center: myLatlng,
 mapTypeId: google.maps.MapTypeId.ROADMAP
var map = new google.maps.Map(document.getElementById("map"), myOptions);
google.maps.event.addListener(map, 'idle', function(event) {
 myHeatmap.AddOverlay(this, myHeatmap);

You will also have to create your own proxy page. This is a page that does data gathering and submtis to our webservice, so you can submit large amounts of data cross domains (our webservice is not on your domain, so it requires a proxy page to do it for your website).

This domain must be EXACTLY the same as your web page with a map. The proxy page can be taken from any of our examples below, doesn't need to be in PHP.

Javascript Objects

This is a helper class to create the links to get a URL for your image.

Init(mapWidth, mapHeight);
// Call to Initialize the class values in pixels

// populate the data for your heat map. data is a Javasript Array, where each row is a point, where the first column is the latitude, second is longitude and the third is the value at that location.

// This function is not required when using large dataset methods.

// populate the value of the boost for distance. The default is 1 if not set. This value is a multiple. A value less than 1 would indicate that distance is less important, while a value of 2 is twice as important as the default. Valid range would be something from .5 to 3 or so, your choice. Make it too big and it will render slower with more points. We recommend the more points you send it, you lower this value, especially if your map is big (width/height).

// This function is not required, default 1. Call before calling GetURL().

// There are two modes. 1 is average mode, 0 is summation mode. 0 is the default.

// This function is not required, default 0. Call before calling GetURL().

// Sets the location of YOUR proxy server page. This page will make a call to our web service from the url you provide. You'll have to create a page that will be this address provided. An example of how you would do this is below.

Web Service

This is a web service class to aid in proxy calls for cross domain usage in the large data set method.

The webservice is located: http://www.heatmapapi.com/HeatmapGenerate2WS.asmx
(retired function, but still supported)
string GetImagePath(string k, string u, double lat1, double lat2, double lon1, double lon2, string w, string h, string d, string b);
// Returns the string where your heat map is after it is generated. This will be returned for to the existing wrapper API's.
Don't worry about the parameters, just do it like this. This is an example for ASP.NET, you can do it in PHP to Coldfusion, but it must call a SOAP XML Web Service.

new string GetImagePathDecay(string k, string u, double lat1, double lat2, double lon1, double lon2, string w, string h, string d, string b, string x);
// Just like GetImagePath, but takes a double value x, which is how you toggle what mode is being used. The parameter x is 1 for average mode, and 0 for sum mode. This is the function called when you implement our javascript wrapper

new string GetImagePathDecayColor(string k, string u, double lat1, double lat2, double lon1, double lon2, string w, string h, string d, string b, string x, string c);
// Just like GetImagePathDecay, but has a extra parameter (string c), which is the color pallette. The fixed palettes available are one of the following numbers 1,2,3,4 OR you can pass in a custom palette by sending in a comma seperated list of values for 6 colors, starting from the hottest to the coldest or center to the outside. For example the default colors you would send "#ffffff,#ffff33,#f2be21,#fe2a00,#d50243,#9000ff". If you send custom colors, you must send 6 colors for it to work. If you want to stop the alpha blend (transparancy), simply pass in a 0 for the last param like this: "#ffffff,#ffff33,#f2be21,#fe2a00,#d50243,#9000ff,0" This function is only available when you call the webservice from your proxy page directly.

.NET C# Example (for your proxy page)
string k = Request["k"];
string u = Request["u"];
string lat1 = Request["lat1"];
string lat2 = Request["lat2"];
string lon1 = Request["lon1"];
string lon2 = Request["lon2"];
string b = Request["b"];
string w = Request["w"];
string h = Request["h"];
string d = Request["d"];

string x = Request["x"];

hmWS.HeatmapGenerate2WS hm = new hmWS.HeatmapGenerate2WS();
string path = hm.GetImagePathDecayColor(k, u, Convert.ToDouble(lat1), Convert.ToDouble(lat2), Convert.ToDouble(lon1), Convert.ToDouble(lon2), w, h, d, b, x, "1");

Response.Write(path); // Just write out the path we got, the javascript api knows what to do.

Classic ASP VB Example (for your proxy page)
<%@ Language=VBScript %>
' Install this library from microsoft
' http://www.microsoft.com/downloads/details.aspx?FamilyID=c943c0dd-ceec-4088-9753-86f052ec8450&DisplayLang=en

dim oWS
Set oWS = CreateObject("MSSOAP.SOAPClient30")
oWS.ClientProperty("ServerHTTPRequest") = True

dim data
data = Request.Form("d")
result = oWS.GetImagePathDecayColor(Request("k"), Request("u"), Request("lat1"), Request("lat2"), Request("lon1"), Request("lon2"), Request("w"), Request("h"), data, Request("b"), Request("x"), "1")


PHP Example (for your proxy page)
class RequestParams {
public $k;
public $u;
public $lat1;
public $lat2;
public $lon1;
public $lon2;
public $w;
public $h;
public $d;
public $b;
public $x;
$parameters = new RequestParams();
$parameters->k = $_REQUEST['k'];
$parameters->u = $_REQUEST['u'];
$parameters->lat1 = $_REQUEST['lat1'];
$parameters->lat2 = $_REQUEST['lat2'];
$parameters->lon1 = $_REQUEST['lon1'];
$parameters->lon2 = $_REQUEST['lon2'];
$parameters->w = $_REQUEST['w'];
$parameters->h = $_REQUEST['h'];
$parameters->d = $_REQUEST['d'];
$parameters->b = $_REQUEST['b'];
$parameters->x = $_REQUEST['x'];
$parameters->c = '1';

$client = new SoapClient("http://www.heatmapapi.com/HeatmapGenerate2WS.asmx?wsdl");

print $i->GetImagePathDecayColorResult;
catch (Exception $e) {
echo $e -> getMessage ();

Java Example (for your proxy page)
// 1th create web Service client with netbeans(6.5) or eclipse in your project
// and set: WSDL url : http://www.heatmapapi.com/HeatmapGenerate2WS.asmx?wsdl
try {
String k=request.getParameter("k");
String u=request.getParameter("u");
Double lat1=Double.parseDouble(
Double lat2=Double.parseDouble(request.getParameter("lat2"));
Double lon1=Double.parseDouble(request.getParameter("lon1"));
Double lon2=Double.parseDouble(request.getParameter("lon2"));
String b=request.getParameter("b");
String w=request.getParameter("w");
String h=request.getParameter("h");
String d=request.getParameter("d");
String x=request.getParameter("x");
String c="1";
org.tempuri.HeatmapGenerate2WS service=new org.tempuri.HeatmapGenerate2WS();
String path = service.getHeatmapGenerate2WSSoap().getImagePathDecayColor(k,u,lat1,lat2,lon1,lon2,w,h,d,b,x,c);
} catch(Exception e){

Ruby on Rails Example (for your proxy page) 'thanks J McAliley' new
require 'soap/wsdlDriver'
class HeatMapController < ApplicationController
 protect_from_forgery :except => :heat_map_proxy

 def heat_map_proxy
   wsdl = 'http://www.heatmapapi.com/HeatmapGenerate2WS.asmx?wsdl'
   driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
   response = driver.GetImagePathDecay(:k=>params['k'],:u=>params['u'],:lat1=>params['lat1'],
   render :text=>response["GetImagePathDecayResult"]

ColdFusion Example (for your proxy page) Thanks to ProFairs
<CFSET requestparams = structnew() />
<CFSET requestparams['k'] = FORM.k />
<CFSET requestparams['u'] = FORM.u />
<CFSET requestparams['lat1'] = FORM.lat1 />
<CFSET requestparams['lat2'] = FORM.lat2 />
<CFSET requestparams['lon1'] = FORM.lon1 />
<CFSET requestparams['lon2'] = FORM.lon2 />
<CFSET requestparams['w'] = FORM.w />
<CFSET requestparams['h'] = FORM.h />
<CFSET requestparams['d'] = FORM.d />
<CFSET requestparams['b'] = FORM.b />
<CFSET requestparams['x'] = FORM.x />

argumentcollection="#requestparams#" />

<CFCONTENT reset="true"><CFOUTPUT>#GetImagePathDecayResult#</CFOUTPUT><CFABORT />

<CFCATCH type="any">
<CFDUMP var="#cfcatch#" />

The documentation is being updated frequently. Please check back soon often.

Copyright 2008-2012, HeatMapAPI.com