I am using the Javascript SDK (4.33.14) and map components (4.33.23) in a React (19.1.0) and Vite (7.0.0) application. I am displaying a point GeoJSON Layer with ~1000 features with no issues. However, when I set labelingInfo, it errors out with the error "Uncaught RangeError: Invalid array length" 235 times. I have double checked the syntax I'm using. I have tried adding the simplest of labels, using different attributes for the label, and installing newer versions of the Javascript SDK and map components (to no avail).
To test labels out in general, I tried adding a label to a separate polygon Feature Layer, but that causes the infinite error "Uncaught TypeError: Cannot destructure property 'vertexStart' of 'e14[s11]' as it is undefined." I'm not sure if that is related or not. I have attached pictures of the console messages.
Here are the relevant parts of the code I'm using:
const viewRef = useRef();
const aLayer = useRef();
const blob = new Blob([JSON.stringify(geojsonData)], {
type: "application/json",
});
const url = URL.createObjectURL(blob);
const labelClass = {
symbol: {
type: "text",
color: "black",
font: {
family: "Noto Sans",
size: 14,
},
},
labelExpressionInfo: {
expression: "$feature.c",
},
};
aLayer.current = new GeoJSONLayer({
title: "Locations",
url: url,
popupEnabled: true,
popupTemplate: popupTemplate,
renderer: uniqueRenderer,
labelingInfo: [labelClass],
});
viewRef.current.map.add(aLayer.current);
Thank you for any help!
Solved! Go to Solution.
Updating the version must have fixed it. I was using Javascript SDK (4.33.9) and map components (4.33.0) originally. Now I am using Javascript SDK (4.33.14) and map components (4.33.23) and the labels are working. I had to restart for the changes to kick in.
I should add: this code is called after the view is ready. Also, none of the GeoJSON attributes are missing or null.
Updating the version must have fixed it. I was using Javascript SDK (4.33.9) and map components (4.33.0) originally. Now I am using Javascript SDK (4.33.14) and map components (4.33.23) and the labels are working. I had to restart for the changes to kick in.