I've already asked numerous questions concerning the project I'm working on now and have hit yet another wall. I'm storing an array of Google Map markers in localStorage as a means to store searched history from the user. When I pull the data back out of localStorage via parse and retrocycle it, it appears they are no longer "Marker" objects anymore. Despite this, I still see most of the values that I should (i.e. a latitude and a longitude (only they aren't really named that)).
Here is my code:
var markers = [];
var cache = localStorage.getItem("searchHistory");
testCache = JSON.retrocycle(JSON.parse(cache));
for(i = 0; i < testCache.length; i++)
{
newMarker = new google.maps.Marker({
map: map,
title: //what to do here?
position: //what to do here?
});
markers.push(newMarker);
}
//On places_changed create new marker for location
addListenerToMarker(map,marker);
if(!markerExistsInMarkers(marker,markers))
{
markers.push(marker);
localStorage.setItem("searchHistory",JSON.stringify(JSON.decycle(markers)));
}
I've tried several things like:
position: new google.maps.LatLng(testCache[i][1],testCache[i][2])
Which supposedly worked for someone but it's showing up as NaN for me.
And:
position: testCache[i].position
Doesn't work because it's not a marker object anymore. How can I access the fields in testCache in such a way that they return what I want them to?