I get this error when trying to pass a geojson object from the view context to a map:
django can’t serialize object of unregistered class HTMLScriptElement
in my template I have:
{{top7d_starts|json_script:"top7d_starts"}}
and in my map.js:
var top7d_starts = document.getElementById('top7d_starts');
The error occurs on this code for mapLibre:
map.on('load', () => {
map.addSource('starts', {
type: 'geojson',
data: top7d_starts
});
});
The geojson object is already serialized.
What steps am I missing? Or is there a better way to bring a geojson object from the view context to the js map?