0

I have the following code in order to click on a map and get the latitude and longitude coordinates. After clicking on the map, the marker appears at that exact point along with a radius circle around the marker. After that a cookie is being created with the coordinates.

 var marker;
        function placeMarker(location) {
            if (marker) {
                marker.setPosition(location);
            } else {
                marker = new google.maps.Marker({
                    position: location,
                    map: map
                });

                var circle = new google.maps.Circle({
                    map: map,
                    radius: 24140,    // 15 miles in metres
                    fillColor: '#08aa23'
                });
                circle.bindTo('center', marker, 'position');
            }

            document.getElementById('lat').value = location.lat();
            document.getElementById('lng').value = location.lng();
            getAddress(location);
            var cookie_val = ('other_lat_lng', location.lat() + "," + location.lng())
            document.cookie = "other_lat_lng=" + escape(cookie_val);
        }

I was wondering if there is a way I can retain the marker position on a page refresh by using the coordinates cookie?

Theopap
  • 715
  • 1
  • 10
  • 33

0 Answers0