HeatmapLayer.js

  • HeatmapLayer()

    HeatmapLayer's constructor

  • setData()

    Sets new data for the HeatmapLayer. Will remove old data.

  • addData()

    Adds data to the HeatmapLayer. Will not remove old data.

  • setMax()

    Sets the new maximum value for the data set. Inherently affects the color distribution in the Heatmap.

  • setRadius()

    Sets the radius for each point in the data set.

  • setBlur()

    Sets the blur value for each point in the data set.

  • setGradient()

    Sets the gradient colors of the Heatmap.

  • getLayerContentBounds()

    Returns layer content bounds

HeatmapLayer()


constructor
Inherits from CanvasLayer

The layer class responsible for adding heat maps

Options:
  • clipOffset(Number)The clip offset (Default: 100)
  • radius(Number)The radius of each point from the data set (Default: 20)
  • blur(Number)The blur of each point from the data set (Default: 10)
  • gradient(Object)The colors of the heat map, represented as percentage 'stops' for each color. Acceppts both Color Names and RGB Color Codes (Default: {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow',1.0: 'red'})
Parameter Type Description
options Object The HeatmapLayer options

Example

$(document).ready(function(){

    var mapContainer = T.DomUtil.get("map"),
        mapoLayer = new T.TibcoLayer({name: "Tile"}),
        heatmapLayer = new T.HeatmapLayer({name: "Heatmap", radius: 5, blur: 4}),

        layersControl = new T.LayersControl({
            offset: [10, 10]
        });


    var map = new T.Map(
        mapContainer,
        {
            zoom: 12,
            center: new T.LatLng(37.782551, -122.43),
            urlLocation: false
        }
    );

    // Add layers to map
    map.addLayer(mapoLayer);
    map.addLayer(heatmapLayer);

    // Add layers control
    map.addControl(layersControl);

    var heatmapData = [[37.782551, -122.445368, 1], [37.782745, -122.444586, 1], [37.782842, -122.443688, 1], [37.782919, -122.442815, 1], [37.782992, -122.442112, 1], [37.783100, -122.441461, 1], [37.783206, -122.440829, 1], [37.783273, -122.440324, 1], [37.783316, -122.440023, 1], [37.783357, -122.439794, 1], [37.783371, -122.439687, 1], [37.783368, -122.439666, 1], [37.783383, -122.439594, 1], [37.783508, -122.439525, 1], [37.783842, -122.439591, 1], [37.784147, -122.439668, 1], [37.784206, -122.439686, 1], [37.784386, -122.439790, 1], [37.784701, -122.439902, 1], [37.784965, -122.439938, 1], [37.785010, -122.439947, 1], [37.785360, -122.439952, 1], [37.785715, -122.440030, 1], [37.786117, -122.440119, 1], [37.786564, -122.440209, 1], [37.786905, -122.440270, 1], [37.786956, -122.440279, 1], [37.800224, -122.433520, 1], [37.800155, -122.434101, 1], [37.800160, -122.434430, 1], [37.800378, -122.434527, 1], [37.800738, -122.434598, 1], [37.800938, -122.434650, 1], [37.801024, -122.434889, 1], [37.800955, -122.435392, 1], [37.800886, -122.435959, 1], [37.800811, -122.436275, 1], [37.800788, -122.436299, 1], [37.800719, -122.436302, 1], [37.800702, -122.436298, 1], [37.800661, -122.436273, 1], [37.800395, -122.436172, 1], [37.800228, -122.436116, 1], [37.800169, -122.436130, 1], [37.800066, -122.436167, 1], [37.784345, -122.422922, 1], [37.784389, -122.422926, 1], [37.784437, -122.422924, 1], [37.784746, -122.422818, 1], [37.785436, -122.422959, 1], [37.786120, -122.423112, 1], [37.786433, -122.423029, 1], [37.786631, -122.421213, 1], [37.786660, -122.421033, 1], [37.786801, -122.420141, 1], [37.786823, -122.420034, 1], [37.786831, -122.419916, 1], [37.787034, -122.418208, 1], [37.787056, -122.418034, 1], [37.787169, -122.417145, 1], [37.787217, -122.416715, 1], [37.786144, -122.416403, 1], [37.785292, -122.416257, 1], [37.780666, -122.390374, 1], [37.780501, -122.391281, 1], [37.780148, -122.392052, 1], [37.780173, -122.391148, 1], [37.780693, -122.390592, 1], [37.781261, -122.391142, 1], [37.781808, -122.391730, 1], [37.782340, -122.392341, 1], [37.782812, -122.393022, 1], [37.783300, -122.393672, 1], [37.783809, -122.394275, 1], [37.784246, -122.394979, 1], [37.784791, -122.395958, 1], [37.785675, -122.396746, 1], [37.786262, -122.395780, 1], [37.786776, -122.395093, 1], [37.787282, -122.394426, 1], [37.787783, -122.393767, 1], [37.788343, -122.393184, 1], [37.788895, -122.392506, 1], [37.789371, -122.391701, 1], [37.789722, -122.390952, 1], [37.790315, -122.390305, 1], [37.790738, -122.389616, 1], [37.779448, -122.438702, 1], [37.779023, -122.438585, 1], [37.778542, -122.438492, 1], [37.778100, -122.438411, 1], [37.777986, -122.438376, 1], [37.777680, -122.438313, 1], [37.777316, -122.438273, 1], [37.777135, -122.438254, 1], [37.776987, -122.438303, 1], [37.776946, -122.438404, 1], [37.776944, -122.438467, 1], [37.776892, -122.438459, 1], [37.776842, -122.438442, 1], [37.776822, -122.438391, 1], [37.776814, -122.438412, 1], [37.776787, -122.438628, 1], [37.776729, -122.438650, 1], [37.776759, -122.438677, 1], [37.776772, -122.438498, 1], [37.776787, -122.438389, 1], [37.776848, -122.438283, 1], [37.776870, -122.438239, 1], [37.777015, -122.438198, 1], [37.777333, -122.438256, 1], [37.777595, -122.438308, 1], [37.777797, -122.438344, 1], [37.778160, -122.438442, 1], [37.778414, -122.438508, 1], [37.778445, -122.438516, 1], [37.778503, -122.438529, 1], [37.778607, -122.438549, 1], [37.778670, -122.438644, 1], [37.778847, -122.438706, 1], [37.779240, -122.438744, 1], [37.779738, -122.438822, 1], [37.780201, -122.438882, 1], [37.780400, -122.438905, 1], [37.780501, -122.438921, 1], [37.780892, -122.438986, 1], [37.781446, -122.439087, 1], [37.781985, -122.439199, 1], [37.782239, -122.439249, 1], [37.782286, -122.439266, 1], [37.797847, -122.429388, 1], [37.797874, -122.429180, 1], [37.797885, -122.429069, 1], [37.797887, -122.429050, 1], [37.797933, -122.428954, 1], [37.798242, -122.428990, 1], [37.798617, -122.429075, 1], [37.798719, -122.429092, 1], [37.798944, -122.429145, 1], [37.799320, -122.429251, 1], [37.799590, -122.429309, 1], [37.799677, -122.429324, 1], [37.799966, -122.429360, 1], [37.800288, -122.429430, 1], [37.800443, -122.429461, 1], [37.800465, -122.429474, 1], [37.800644, -122.429540, 1], [37.800948, -122.429620, 1], [37.801242, -122.429685, 1], [37.801375, -122.429702, 1], [37.801400, -122.429703, 1], [37.801453, -122.429707, 1], [37.801473, -122.429709, 1], [37.801532, -122.429707, 1], [37.801852, -122.429729, 1], [37.802173, -122.429789, 1], [37.802459, -122.429847, 1], [37.802554, -122.429825, 1], [37.802647, -122.429549, 1], [37.802693, -122.429179, 1], [37.802729, -122.428751, 1], [37.766104, -122.409291, 1], [37.766103, -122.409268, 1], [37.766138, -122.409229, 1], [37.766183, -122.409231, 1], [37.766153, -122.409276, 1], [37.766005, -122.409365, 1], [37.765897, -122.409570, 1], [37.765767, -122.409739, 1], [37.765693, -122.410389, 1], [37.765615, -122.411201, 1], [37.765533, -122.412121, 1], [37.765467, -122.412939, 1], [37.765444, -122.414821, 1], [37.765444, -122.414964, 1], [37.765318, -122.415424, 1], [37.763961, -122.415296, 1], [37.763115, -122.415196, 1], [37.762967, -122.415183, 1], [37.762278, -122.415127, 1], [37.761675, -122.415055, 1], [37.760932, -122.414988, 1], [37.759337, -122.414862, 1], [37.773187, -122.421922, 1], [37.773043, -122.422118, 1], [37.773007, -122.422165, 1], [37.772979, -122.422219, 1], [37.772865, -122.422394, 1], [37.772779, -122.422503, 1], [37.772676, -122.422701, 1], [37.772606, -122.422806, 1], [37.772566, -122.422840, 1], [37.772508, -122.422852, 1], [37.772387, -122.423011, 1], [37.772099, -122.423328, 1], [37.771704, -122.423783, 1], [37.771481, -122.424081, 1], [37.771400, -122.424179, 1], [37.771352, -122.424220, 1], [37.771248, -122.424327, 1], [37.770904, -122.424781, 1], [37.770520, -122.425283, 1], [37.770337, -122.425553, 1], [37.770128, -122.425832, 1], [37.769756, -122.426331, 1], [37.769300, -122.426902, 1], [37.769132, -122.427065, 1], [37.769092, -122.427103, 1], [37.768979, -122.427172, 1], [37.768595, -122.427634, 1], [37.768372, -122.427913, 1], [37.768337, -122.427961, 1], [37.768244, -122.428138, 1], [37.767942, -122.428581, 1], [37.767482, -122.429094, 1], [37.767031, -122.429606, 1], [37.766732, -122.429986, 1], [37.766680, -122.430058, 1], [37.766633, -122.430109, 1], [37.766580, -122.430211, 1], [37.766367, -122.430594, 1], [37.765910, -122.431137, 1], [37.765353, -122.431806, 1], [37.764962, -122.432298, 1], [37.764868, -122.432486, 1], [37.764518, -122.432913, 1], [37.763435, -122.434173, 1], [37.762847, -122.434953, 1], [37.762291, -122.435935, 1], [37.762224, -122.436074, 1], [37.761957, -122.436892, 1], [37.761652, -122.438886, 1], [37.761284, -122.439955, 1], [37.761210, -122.440068, 1], [37.761064, -122.440720, 1], [37.761040, -122.441411, 1], [37.761048, -122.442324, 1], [37.760851, -122.443118, 1], [37.759977, -122.444591, 1], [37.759913, -122.444698, 1], [37.759623, -122.445065, 1], [37.758902, -122.445158, 1], [37.758428, -122.444570, 1], [37.757687, -122.443340, 1], [37.757583, -122.443240, 1], [37.757019, -122.442787, 1], [37.756603, -122.442322, 1], [37.756380, -122.441602, 1], [37.755790, -122.441382, 1], [37.754493, -122.442133, 1], [37.754361, -122.442206, 1], [37.753719, -122.442650, 1], [37.753096, -122.442915, 1], [37.751617, -122.443211, 1], [37.751496, -122.443246, 1], [37.750733, -122.443428, 1], [37.750126, -122.443536, 1], [37.750103, -122.443784, 1], [37.750390, -122.444010, 1], [37.750448, -122.444013, 1], [37.750536, -122.444040, 1], [37.750493, -122.444141, 1], [37.790859, -122.402808, 1], [37.790864, -122.402768, 1], [37.790995, -122.402539, 1], [37.791148, -122.402172, 1], [37.791385, -122.401312, 1], [37.791405, -122.400776, 1], [37.791288, -122.400528, 1], [37.791113, -122.400441, 1], [37.791027, -122.400395, 1], [37.791094, -122.400311, 1], [37.791211, -122.400183, 1], [37.791060, -122.399334, 1], [37.790538, -122.398718, 1], [37.790095, -122.398086, 1], [37.789644, -122.397360, 1], [37.789254, -122.396844, 1], [37.788855, -122.396397, 1], [37.788483, -122.395963, 1], [37.788015, -122.395365, 1], [37.787558, -122.394735, 1], [37.787472, -122.394323, 1], [37.787630, -122.394025, 1], [37.787767, -122.393987, 1], [37.787486, -122.394452, 1], [37.786977, -122.395043, 1], [37.786583, -122.395552, 1], [37.786540, -122.395610, 1], [37.786516, -122.395659, 1], [37.786378, -122.395707, 1], [37.786044, -122.395362, 1], [37.785598, -122.394715, 1], [37.785321, -122.394361, 1], [37.785207, -122.394236, 1], [37.785751, -122.394062, 1], [37.785996, -122.393881, 1], [37.786092, -122.393830, 1], [37.785998, -122.393899, 1], [37.785114, -122.394365, 1], [37.785022, -122.394441, 1], [37.784823, -122.394635, 1], [37.784719, -122.394629, 1], [37.785069, -122.394176, 1], [37.785500, -122.393650, 1], [37.785770, -122.393291, 1], [37.785839, -122.393159, 1], [37.782651, -122.400628, 1], [37.782616, -122.400599, 1], [37.782702, -122.400470, 1], [37.782915, -122.400192, 1], [37.783137, -122.399887, 1], [37.783414, -122.399519, 1], [37.783629, -122.399237, 1], [37.783688, -122.399157, 1], [37.783716, -122.399106, 1], [37.783798, -122.399072, 1], [37.783997, -122.399186, 1], [37.784271, -122.399538, 1], [37.784577, -122.399948, 1], [37.784828, -122.400260, 1], [37.784999, -122.400477, 1], [37.785113, -122.400651, 1], [37.785155, -122.400703, 1], [37.785192, -122.400749, 1], [37.785278, -122.400839, 1], [37.785387, -122.400857, 1], [37.785478, -122.400890, 1], [37.785526, -122.401022, 1], [37.785598, -122.401148, 1], [37.785631, -122.401202, 1], [37.785660, -122.401267, 1], [37.803986, -122.426035, 1], [37.804102, -122.425089, 1], [37.804211, -122.424156, 1], [37.803861, -122.423385, 1], [37.803151, -122.423214, 1], [37.802439, -122.423077, 1], [37.801740, -122.422905, 1], [37.801069, -122.422785, 1], [37.800345, -122.422649, 1], [37.799633, -122.422603, 1], [37.799750, -122.421700, 1], [37.799885, -122.420854, 1], [37.799209, -122.420607, 1], [37.795656, -122.400395, 1], [37.795203, -122.400304, 1], [37.778738, -122.415584, 1], [37.778812, -122.415189, 1], [37.778824, -122.415092, 1], [37.778833, -122.414932, 1], [37.778834, -122.414898, 1], [37.778740, -122.414757, 1], [37.778501, -122.414433, 1], [37.778182, -122.414026, 1], [37.777851, -122.413623, 1], [37.777486, -122.413166, 1], [37.777109, -122.412674, 1], [37.776743, -122.412186, 1], [37.776440, -122.411800, 1], [37.776295, -122.411614, 1], [37.776158, -122.411440, 1], [37.775806, -122.410997, 1], [37.775422, -122.410484, 1], [37.775126, -122.410087, 1], [37.775012, -122.409854, 1], [37.775164, -122.409573, 1], [37.775498, -122.409180, 1], [37.775868, -122.408730, 1], [37.776256, -122.408240, 1], [37.776519, -122.407928, 1], [37.776539, -122.407904, 1], [37.776595, -122.407854, 1], [37.776853, -122.407547, 1], [37.777234, -122.407087, 1], [37.777644, -122.406558, 1], [37.778066, -122.406017, 1], [37.778468, -122.405499, 1], [37.778866, -122.404995, 1], [37.779295, -122.404455, 1], [37.779695, -122.403950, 1], [37.779982, -122.403584, 1], [37.780295, -122.403223, 1], [37.780664, -122.402766, 1], [37.781043, -122.402288, 1], [37.781399, -122.401823, 1], [37.781727, -122.401407, 1], [37.781853, -122.401247, 1], [37.781894, -122.401195, 1], [37.782076, -122.400977, 1], [37.782338, -122.400603, 1], [37.782666, -122.400133, 1], [37.783048, -122.399634, 1], [37.783450, -122.399198, 1], [37.783791, -122.398998, 1], [37.784177, -122.398959, 1], [37.784388, -122.398971, 1], [37.784404, -122.399128, 1], [37.784586, -122.399524, 1], [37.784835, -122.399927, 1], [37.785116, -122.400307, 1], [37.785282, -122.400539, 1], [37.785346, -122.400692, 1], [37.765769, -122.407201, 1], [37.765790, -122.407414, 1], [37.765802, -122.407755, 1], [37.765791, -122.408219, 1], [37.765763, -122.408759, 1], [37.765726, -122.409348, 1], [37.765716, -122.409882, 1], [37.765708, -122.410202, 1], [37.765705, -122.410253, 1], [37.765707, -122.410369, 1], [37.765692, -122.410720, 1], [37.765699, -122.411215, 1], [37.765687, -122.411789, 1], [37.765666, -122.412373, 1], [37.765598, -122.412883, 1], [37.765543, -122.413039, 1], [37.765532, -122.413125, 1], [37.765500, -122.413553, 1], [37.765448, -122.414053, 1], [37.765388, -122.414645, 1], [37.765323, -122.415250, 1], [37.765303, -122.415847, 1], [37.765251, -122.416439, 1], [37.765204, -122.417020, 1], [37.765172, -122.417556, 1], [37.765164, -122.418075, 1], [37.765153, -122.418618, 1], [37.765136, -122.419112, 1], [37.765129, -122.419378, 1], [37.765119, -122.419481, 1], [37.765100, -122.419852, 1], [37.765083, -122.420349, 1], [37.765045, -122.420930, 1], [37.764992, -122.421481, 1], [37.764980, -122.421695, 1], [37.764993, -122.421843, 1], [37.764986, -122.422255, 1], [37.764975, -122.422823, 1], [37.764939, -122.423411, 1], [37.764902, -122.424014, 1], [37.764853, -122.424576, 1], [37.764826, -122.424922, 1], [37.764796, -122.425375, 1], [37.764782, -122.425869, 1], [37.764768, -122.426089, 1], [37.764766, -122.426117, 1], [37.764723, -122.426276, 1], [37.764681, -122.426649, 1], [37.782012, -122.404200, 1], [37.781574, -122.404911, 1], [37.781055, -122.405597, 1], [37.780479, -122.406341, 1], [37.779996, -122.406939, 1], [37.779459, -122.407613, 1], [37.778953, -122.408228, 1], [37.778409, -122.408839, 1], [37.777842, -122.409501, 1], [37.777334, -122.410181, 1], [37.776809, -122.410836, 1], [37.776240, -122.411514, 1], [37.775725, -122.412145, 1], [37.775190, -122.412805, 1], [37.774672, -122.413464, 1], [37.774084, -122.414186, 1], [37.773533, -122.413636, 1], [37.773021, -122.413009, 1], [37.772501, -122.412371, 1], [37.771964, -122.411681, 1], [37.771479, -122.411078, 1], [37.770992, -122.410477, 1], [37.770467, -122.409801, 1], [37.770090, -122.408904, 1], [37.769657, -122.408103, 1], [37.769132, -122.407276, 1], [37.768564, -122.406469, 1], [37.767980, -122.405745, 1], [37.767380, -122.405299, 1], [37.766604, -122.405297, 1], [37.765838, -122.405200, 1], [37.765139, -122.405139, 1], [37.764457, -122.405094, 1], [37.763716, -122.405142, 1], [37.762932, -122.405398, 1], [37.762126, -122.405813, 1], [37.761344, -122.406215, 1], [37.760556, -122.406495, 1], [37.759732, -122.406484, 1], [37.758910, -122.406228, 1], [37.758182, -122.405695, 1], [37.757676, -122.405118, 1], [37.757039, -122.404346, 1], [37.756335, -122.403719, 1], [37.755503, -122.403406, 1], [37.754665, -122.403242, 1], [37.753837, -122.403172, 1], [37.752986, -122.403112, 1], [37.751266, -122.403355, 1]];


    heatmapLayer.setData(heatmapData);
    heatmapLayer.setMax(4);





});
<html>

    <head>
        <title>TibcoMaps - Vector events demo</title>
        <meta charset="UTF-8">

        <!-- CSS -->
        <link rel="stylesheet", href="heatmap-layer.css"/>
        <link rel="stylesheet" type="text/css" href='../lib/GeoAnalytics.css'>

        <!-- Javascript -->
        <script type="text/javascript" src='../lib/GeoAnalytics.js'></script>
        <script type="text/javascript" src='../lib/jquery-1.9.1.min.js'></script>
        <script type="text/javascript" src="heatmap-layer.js"></script>
    </head>

    <body>
        <div class="custom-container">
            <div id="map"></div>
        </div>
    </body>
</html>
body {
    width: 100%;
    height: 100%;
}

.custom-container {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

#map {
    width: 100%;
    height: 100%;
}

setData()


method

Sets new data for the HeatmapLayer. Will remove old data.

Parameter Type Description
data Array HeatmapLayer data in form of an array of arrays (ex: [lattitude, longitude, weight/value]), or array of objects; in the latter case, use dataFunction param
dataFunction Function (Optional) Data function which transform each element into an array with the following structure: [lattitude, longitude, weight/value]

addData()


method

Adds data to the HeatmapLayer. Will not remove old data.

Parameter Type Description
data Array HeatmapLayer data in form of an array of arrays (ex: [ lattitude, longitude, weight/value]), or array of objects; in the latter case, use dataFunction param
dataFunction Function (Optional) Data function which transform each element into an array with the following structure: [ lattitude, longitude,weight/value]

setMax()


method

Sets the new maximum value for the data set. Inherently affects the color distribution in the Heatmap.

Parameter Type Description
max Number The new maximum value

setRadius()


method

Sets the radius for each point in the data set.

Parameter Type Description
radius Number The new radius value

setBlur()


method

Sets the blur value for each point in the data set.

Parameter Type Description
blur Number The new blur value

setGradient()


method

Sets the gradient colors of the Heatmap.

Parameter Type Description
gradient Object The new gradient value.
The object should have the following structure:
{
0.2: 'blue',
0.4: 'cyan',
0.6: 'rgb(0, 255, 0)',
1.0: 'rgb(255, 0, 0)',
}

You can use both Color Names and RGB Color Codes

getLayerContentBounds()


method

Returns layer content bounds

returns
LatLngBounds - Layer content bounds