如何修复Uncaught TypeError:无法分配为只读对象'#<imagedata>'的属性'data'

时间:2019-02-12 08:35:18

标签: javascript leaflet salesforce heatmap

我正在尝试将数据添加到我的热图。 我使用这个库是为了做到这一点 https://github.com/pa7/heatmap.js +插件。

这是我的导入

<ltng:require styles='/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.css, 
                      /resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.Default.css'
              scripts='/resource/leaflet/leaflet.js,/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js, 
                       /resource/LeafletHeatmapLayer/heatmap.js-develop/build/heatmap.js,
                       /resource/LeafletHeatmapLayer/heatmap.js-develop/plugins/leaflet-heatmap/leaflet-heatmap.js'
              afterScriptsLoaded="{!c.jsLoaded}" />

帐户已定义:

locationsAccounts[i]=helper.heatpoint(account.ShippingLatitude, account.ShippingLongitude,1);

heatpoint: function Person(latitude, longitude, counter) {
  return {
    lat: latitude,
    lng: longitude,
    count: counter
  };
}

var testData = { max: accounts.length,
                 data: locationsAccounts };

heatmapLayer.setData(testData);

热图属于L.control.layers是叠加层之一。

更新我看到在即时消息调试时,我在addData和setData方法中遇到此问题: 异常:TypeError:在严格模式函数或在Function.invokeGetter

上对其调用的参数对象上,可能无法访问'caller','callee'和'arguments'属性

1 个答案:

答案 0 :(得分:0)

我假设您是调试器在此位置中断。这是一段代码,有意破坏“严格”模式规则以生成错误,以便可以从产生的错误中提取调用堆栈。如果您可以在调试器设置中忽略此错误类型,那么Chrome调试器将不再烦您。仅当Dexie.debug === true(这是从localhost服务的站点的默认设置)时,才会发生这种情况。您在控制台日志中获得的功能是未处理拒绝的异步堆栈跟踪。您可以通过设置Dexie.debug = false来显式关闭它。

源代码如下:

export function getErrorWithStack() {
"use strict";
if (NEEDS_THROW_FOR_STACK) try {
    // Doing something naughty in strict mode here to trigger a specific error
    // that can be explicitely ignored in debugger's exception settings.
    // If we'd just throw new Error() here, IE's debugger's exception settings
    // will just consider it as "exception thrown by javascript code" which is
    // something you wouldn't want it to ignore.
    getErrorWithStack.arguments;
    throw new Error(); // Fallback if above line don't throw.
} catch(e) {
    return e;
}
return new Error();
}