hello,
I am working on a web application which is using google map api.
The problem is that when the page will refresh than creating a new map object.
So I want to store this map object in a cookie on first time page load.
If cookie will be null then "setCookee" if cookie is not null then map object get value form "Cookie".
here is sample code.
var map
var lati = 25; // initial latitude
var longi = 76; // initial longitude
var latlng = new google.maps.LatLng(lati, longi);
var opt =
{
center: latlng,
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var mapCookieCheck=getMapCookie("mapCookie");
if(mapCookieCheck=='undefined' ||mapCookieCheck=="")
{
map = new google.maps.Map(document.getElementById("map"), opt);
setMapCookie("mapCookie", map, 365);
}
else
{
debugger
map = mapCookieCheck;
}
function setMapCookie(cName, cValue, expDays)
{
debugger
var d = new Date();
d.setTime(d.getTime()+ (expDays *24*24*60*1000));
var expires="expires="+d.toUTCString();
document.cookie= cName +"=" + cValue + ";" + expires;
}
Please resolve this problem.