I'm trying to save an array consisting of multiple features via localStorage.
var featureArray=[];
map.on('click', function(evt) {
if (feature) {
featureArray.push(feature.values_);
}
});
function saveFeatures() {
localStorage.setItem('features', featureArray);
}
saveFeatures();
Via console console.log(featureArray);
looks fine, but when I try to load them via localStorage.getItem('features')
the output (after two clicks) is something like:
[object Object],[object Object]
But I actually want the values behind this structure to be saved:
I tried JSON.stringify(featureArray) but that throws the error
TypeError: Converting circular structure to JSON
What am I doing wrong?