I have a google maps which works fine.
I populate the Map's markers/locations like so:
var locations = [
['Test 1', 'somewhere', 'map-marker-icon.png']
,
['Test 2', 'London', 'map-marker-icon.png']
,
['Test 3', 'essex', 'map-marker-icon.png']
,
];
Now, if I run my code like that with all the locations inside my HTML file like above, my code works fine and all the markers are being shown on my map.
However, I also have the exact same locations stored in localstorage and I can see them in Firestorage/Firbug.
The localstorage looks like this:
['Test 1', 'somewhere', 'map-marker-icon.png']
,
['Test 2', 'London', 'map-marker-icon.png']
,
['Test 3', 'essex', 'map-marker-icon.png']
,
So I tried to use the localstorage to create the Map's Markers like so:
var nowMarker = localStorage.getItem('mapMarkers');
var locations = [
nowMarker
];
but this doesn't work at all and I mean i don't get any markers on my map whatsoever!
is this even possible and if so, what is the best way of doing this?
Any help/advise would be appreciated.
Here is a working FIDDLE
If you copy/paste the locations from the top of the page into the var locations = [....]; the code works fine... but when I try to use the same locations/string/array or whatever you will call it, from the localstorage, I get no markers on the map.
EDIT
Based on what Sam's given me in his answer, I tried to change it slightly so I can do it my way but I still cannot make it work!
Here is a FIDDLE
Basically, I set the localstorage first, and then try to get it back and then use it in the locations
.