title: Pass javascript array to another page
body: <p>I was wondering if theres a way to pass an array and its contents to another page for use.</p>
  
  <p>I am using an array to store coordinates that are being used to draw a polyline onto a google map. The array works fine on one page, however when i attempt to call the array to draw the polyline points on another map, it appears the array has been emptied and no polyline points are drawn.</p>
  
  <p>I have attempted to use localStorage with JSON stringify but came across many many issues where google maps wont accept the values ether because they contain values its not expecting, or because it simply cant recognise the format.</p>
  
  <pre><code>var googleLatLng = [],
      latlngs = [];
  
  function storeLatLng( lat, lng ) {
      googleLatLng.push(new google.maps.LatLng(lat, lng));
      latlngs.push([lat, lng]);
  
          // setcoords = JSON.stringify(googleLatLng);
          // localStorage.setItem('GoogleLatLng', setcoords);
  
          // console.log(localStorage.getItem("GoogleLatLng"));
  
          console.log(googleLatLng);
  }
  </code></pre>
  
  <p>This code builds the array from the given coordinates, the function is called from within onSuccess of the watchPosition function through </p>
  
  <pre><code>        storeLatLng(lat, lon);
  </code></pre>
  
  <p>I then want to use the array values within the following function </p>
  
  <pre><code>function finishedWalk() {
          // storedCoords = localStorage.getItem('GoogleLatLng');
          // if(storedCoords) storedCoords = JSON.parse(storedCoords);
          navigator.geolocation.getCurrentPosition(onFinishedSuccess, onFinishedError);
  }
  
      function onFinishedSuccess(position) {
  
      var latitude = position.coords.latitude;
      var longitude = position.coords.longitude;
      coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
  
      storeLatLng(latitude, longitude);
  
          var mapOptions = {
              zoom: 17,
              center: coords,
              mapTypeControl: true,
              mapTypeId: google.maps.MapTypeId.ROADMAP
          };
  
          //create the map, and place it in the HTML map div
          map = new google.maps.Map(document.getElementById("mapPlaceholder"), mapOptions);
  
          if (googleLatLng.length &gt; 0) {
            var path = new google.maps.Polyline({
              path: googleLatLng,
              strokeColor: "#FF0000",
              strokeOpacity: 1.0,
              strokeWeight: 5
            });
            path.setMap(map);
          }
  }
  </code></pre>
  
  <p>which is called onLoad of another page</p>