I'm currently building a geolocation/weather page with Google maps and I'm trying to store an array of marker objects in a JS cookie.
My cookies are based around this: CookieMonster.js
And I'm using this JSON lib: json2.js
Here is my code:
var markers = [];
if (/(^|;)\s*userCookie=/.test(document.cookie))
{
markers = JSON.parse(cm_readCookie("userCookie"));
}
if(!markerExistsInMarkers(marker,markers))
{
markers.push(marker);
cookiemonster.set("userCookie",JSON.stringify(markers),5);
}
var marker = new google.maps.Marker({
map: map,
icon: image,
title: place.name,
position: place.geometry.location
});
Each marker object also has a listener event attached to it, if that matters.
I'm getting a JSON.parse error that says "unexpected character at line 1 column 1 of the JSON data." What do I need to do to stop this error from occurring?
Thanks in advance,
Chase