I'm trying to debug a weird error with Carto and Deck GL. The exact text of the error is as follows:
Uncaught (in promise) CartoAPIError: Map instantiation API request failed Server returned: Not found (404): Connection not found
The relevant code chunk is as follows:
const polyLayer = (deckgl, longitude, latitude) => {
if (longitude && latitude) {
console.log(longitude, latitude)
return new deck.carto.CartoLayer({
id: 'block',
connection: 'bigquery',
type: deck.carto.MAP_TYPES.QUERY,
data: `SELECT dist_miles, geometry AS geom
FROM \`bleeding-out.census_blocks.blocks_optimized\`
WHERE ST_INTERSECTS(ST_GEOGPOINT(${longitude}, ${latitude}), geometry)`,
getFillColor: deck.carto.colorContinuous({
attr: "dist_miles",
domain: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],
colors: [[255, 247, 236, 150],
[254, 232, 200, 150],
[253, 212, 158, 150],
[253, 187, 132, 150],
[252, 141, 89, 150],
[239, 101, 72, 150],
[215, 48, 31, 150],
[179, 0, 0, 150],
[127, 0, 0, 150],
[102, 31, 31, 150],
[77, 0, 0, 150]]
}),
getLineColor: false,
lineWidthMaxPixels: 0,
useDevicePixels:false,
pickable: true,
filled: true
})
}
return null;
}
I've tried Googling this error and there are no references to it. I've also read through the Carto documentation and been through the examples multiple times and have come up with anything that works.
I've also tried using deck.carto.MAP_TYPES.TILESET
with a tileset version of the same data and swapping bqconn
for bigquery
(I've seen both online).
I can see that the lat/long is getting inherited from the console so that's not the problem.
Puzzlingly, inside BigQuery this exact same query totally works:
I'm copy-pasting the qualified name straight from Carto data warehouse so its not a problem there either.
Truly stumped on this one, so any help is appreciated.
The error is in the CartoLayer connection
prop. The connection name is not bigquery
no bqconn
. You need to use the same name you have given to the connection in the CARTO Workspace.