如何在传单地图上显示热图

时间:2019-02-12 10:54:16

标签: javascript leaflet salesforce render heatmap

我想在传单地图上显示热图。

我使用了https://github.com/pa7/heatmap.js中的heatmap.js,但最终仅显示

  

未捕获的TypeError:无法分配为只读属性'data'   对象“#”

所以最终我最终选择了https://github.com/ursudio/leaflet-webgl-heatmap

///我注意到在调试时

heatmapLayer的

setData方法将此作为参数

  

TypeError:“ caller”,“ callee”和“ arguments”属性可能不是   在严格模式函数或用于调用的arguments对象上访问   给他们       在Function.invokeGetter(:2:14)

下面是我的代码

 // I initialize heatmap

 // first function where i define and create map and the heatmap 
 var heatmapLayer = new L.webGLHeatmap({
   size: 25, // diameter-in-pixels
   units: 'px',
    opacity: 0.5,
    alphaRange: 0.4 
});

  var myRenderer = L.canvas({ padding: 0.5 });
     var markers = L.markerClusterGroup( { 
        chunkedLoading: true,
        renderer: myRenderer,
        iconCreateFunction: function  (cluster) {
        var childCount = cluster.getChildCount();

        var c = ' marker-cluster-';
        if (childCount < 10) {
            c += 'small';
        } 
        else if (childCount < 100) {
            c += 'medium';
        } 
            else {
                c += 'large';
            }

            return new L.DivIcon({ html: '<div><span>' + childCount + '</span></div>', 
               className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) 
});
}
         });


 var overlays   = {
                 "Fancy Markers": markers,
         "Fancy Heatmap": heatmapLayer
          };

    L.control.layers(baseLayer, overlays).addTo(map);
    component.set("v.map", map); 
    component.set('v.markers',markers);
    component.set('v.heatLayer',heatmapLayer);

第二个功能

var heatmapLayer = component.get('v.heatLayer');
var locationsAccounts = new Array(accounts.length);    

 for (var i=0, len = accounts.length; i<len; i++) {
          locationsAccounts[i]=[account.ShippingLatitude, 
account.ShippingLongitude,1];

}

  heatmapLayer.setData(locationsAccounts); 

0 个答案:

没有答案