How to fix Uncaught TypeError: Cannot assign to read only property 'data' of object '#<ImageData>'

心已入冬 提交于 2019-12-25 02:55:36

问题


I'm trying to add data to my heatmap. I use this library in order to do that https://github.com/pa7/heatmap.js + the plugin from this.

This is my import:

<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}" />

Accounts are already defined:

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);

Heatmap belongs to L.control.layers is one of the overlay.

UPDATE i saw that when im debugging i have this problem in the addData and setData methods : Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter


回答1:


I assume you're debugger breaks at this location. It's a piece of code that intentionally breaks the "strict" mode rule in order to generate an error so that the call stack can be picked from the resulting error. If you can ignore this error type in the debugger settings, chromium debugger will stop annoying you with it. It will only happen if Dexie.debug === true (which is the default for sites served from localhost). The feature you get in your console log, is an async stack trace of unhandled rejections. You can explicitly turn it off by setting Dexie.debug = false.

The source code looks like:

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();
}


来源:https://stackoverflow.com/questions/54645844/how-to-fix-uncaught-typeerror-cannot-assign-to-read-only-property-data-of-obj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!