Nick Kahn
Nick Kahn

Reputation: 20078

Json.stringify TypeError: Converting circular structure to JSON

Here is the Marker reference

var markers = [];
var marker = new google.maps.Marker({ position: e.latLng, map: map });  
markers.push(marker); // add marker to the global array 

My loop to markers...

    var jsonObj = []; 
    for (var i = 0; i < markers.length; i++)
    {
        jsonObj.push({ latitude: markers[i].position, map: markers[i].map }); //key
    }

    alert(JSON.stringify(jsonObj)); // error 

Upvotes: 1

Views: 2549

Answers (1)

taxicala
taxicala

Reputation: 21769

The problem is that each marker has a reference to the map instance, and the map instance, has an array of markers (Which, redundantly, each one of them has a reference to map).

Upvotes: 2

Related Questions