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.

(retired) API Documentation Version 2 (before December 2010)

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 src="http://www.heatmapapi.com/javascript/HeatmapAPI.aspx?k=(YOUR HEATMAPAPI KEY HERE)" type="text/javascript"></script>
<script src="http://www.heatmapapi.com/javascript/HeatmapAPIGoogle.js" type="text/javascript"></script>
(note: where it says (YOUR HEATMAPAPI KEY HERE) above you put the key you received)
Step 4 In javascript on your page, add the following script:

function initHeatmap()
{
  var myHM = new GEOHeatmap();
  myHM.Init(400, 300);

  var data = new Array();

  // Populate your array with 3 values, lat, lon and value for each point you have.
    See our small set javascript sample

  myHM.SetData(data);
  myHM.SetBoost(1); // optional
  myHM.SetDecay(0); // optional
  var preUrl = myHM.GetURL();

  // Now render in our Google Map
  var heatmapOverlay = new HMGoogleOverlay(preUrl);
  m.addOverlay(heatmapOverlay); // m is your google map
  //note that m above is a variable globally assigned globally
  //elsewhere such as: m = new GMap2(document.getElementById("map"));
}


Then call initHeatmap() in your code after you create your google map. Google will automatically query the URL provided to render your map. Optionally if you are not using google, then you can add the corners of your map, and then just stream the image into your mapping software.

Quick Start (LARGE 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 src="http://www.heatmapapi.com/javascript/HeatmapAPI2.aspx?k=(YOUR HEATMAPAPI KEY HERE)" type="text/javascript"></script>
<script src="http://www.heatmapapi.com/javascript/HeatmapAPIGoogle2.js" type="text/javascript"></script>
(note: where it says (YOUR HEATMAPAPI KEY HERE) above you put the key you received), make sure you put the Google JS file ABOVE the ours.
Notice that in this example we use HeatmapAPI2.aspx and HeatmapAPIGoogle2.js above, which is different than the small set method
Step 4 Add two hidden fields to your page:
<input type="hidden" id="HMMapdata" />
<input type="hidden" name="HMImageURL" id="HMImageURL" />
Step 5 In javascript on your page, add the following script:

function initHeatmap()
{
  var myHM = new GEOHeatmap();
  myHM.Init(400, 300);

  var data = new Array();

  // Populate the field HMMapdata with 3 values, lat, lon and value for each point you have.
    See our large set javascript sample

  myHM.SetBoost(1); // optional
  myHM.SetDecay(0); // optional
  //NOTE YOU NEED TO CREATE A PAGE LIKE THIS BELOW ON YOUR SITE IF YOU ARE ON A PUBLIC INTERNET DOMAIN
  //See below for an example


  var proxyURL = 'http://yourwebsite/HeatmapGenerateProxy.aspx';
  myHM.SetProxyURL(proxyURL); // Step 2b

  var preUrl = myHM.GetURL();

  // Now render in our Google Map
  var heatmapOverlay = new HMGoogleOverlay(preUrl);
  m.addOverlay(heatmapOverlay); // m is your google map
  //note that m above is a variable globally assigned globally
  //elsewhere such as: m = new GMap2(document.getElementById("map"));
}


Then call initHeatmap() in your code after you create your google map. Google will automatically query the URL provided to render your map. Optionally if you are not using google, then you can add the corners of your map, and then just stream the image into your mapping software.

Javascript Objects

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

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

SetData(data);
// 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.

SetBoost(value);
// 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().

SetDecay(value);
// This is a number less than 1. 0 means that there is no decay, all points are boosted if there is other points near (0 is default if not provided). If you provide a value like .01, it will slow the affect on adjacency, so that points that are 'alone', might still show up. A higher number under 1 increases decay, a number closer to 0 will make it not decay as much. MOST users will want to use a value of 0, or a number very close to it. Your value will vary based on the number of points your passing.

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

SetProxyURL(data);
// Sets the location of YOUR proxy server. 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.

NOTE: This is only REQUIRED if your hosting on a domain name other than http://localhost (localhost sites are not restricted by browser cross domain AJAX calls.  But if you are on a regular domain, you'll need to use this function, and create your own proxy page (see an example below).

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

GetURL();
// Call retreive the URL to get the image. This URL will give you the image. If you use our google helper function, there is no need to add anything additional to the URL, if you do not, you must add the following parameters to the URL, they are:
lat1, lat2, lon1, lon2 that indicate the current zoom box where: lat1=northEastLat, lat2=southWestLat, lon1=southWestLon, lon2=northEastLon


Web Service

HeatmapGenerate2WS
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
Methods
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.

(see new version GetImagePathDecay());

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 to control how much boost is transferred into adjacent points. x is a number less than 1, could be as small as .00001 for MANY points.



.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.GetImagePathDecay(k, u, Convert.ToDouble(lat1), Convert.ToDouble(lat2), Convert.ToDouble(lon1), Convert.ToDouble(lon2), w, h, d, b, x);

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
oWS.MSSoapInit("http://www.heatmapapi.com/HeatmapGenerate2WS.asmx?wsdl")

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

Response.Write(result)
%>

PHP Example (for your proxy page)
<?php
try{
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'];

ini_set("soap.wsdl_cache_enabled","0");
$client = new SoapClient("http://www.heatmapapi.com/HeatmapGenerate2WS.asmx?wsdl");
$i=$client->GetImagePathDecay($parameters);

print $i->GetImagePathDecayResult;
}
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(
request.getParameter("lat1"));
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");
org.tempuri.HeatmapGenerate2WS service=new org.tempuri.HeatmapGenerate2WS();
String path = service.getHeatmapGenerate2WSSoap().getImagePathDecay(k,u,lat1,lat2,lon1,lon2,w,h,d,b,x);
out.print(path);
} catch(Exception e){
out.print(e);
}
%>

Ruby on Rails Example (for your proxy page) 'thanks J McAliley'
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'],:lat2=>params['lat2'],:lon1=>params['lon1'],:lon2=>params['lon2'],:w=>params['w'],:h=>params['h'],:d=>params['d'],:b=>params['b'],:x=>params['x']);
   render :text=>response["GetImagePathDecayResult"]
 end
end


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



Copyright 2008-2012, HeatMapAPI.com