It's pretty hard to explain so I'll just show an example.
for(i=1;i<position.length;i++)
{
if(position[i].lat() == position[i-1].lat() && position[i].lng() == position[i-1].lng())
{
position[i].lat = position[i].lat() + ((Math.random() -.5) / 1500);
position[i].lng = position[i].lng() + ((Math.random() -.5) / 1500);
//position[i].lng = position[i].lng() + ((Math.random() -.5) / 1500);
//console.log(position[i].lat().value);
}
}
Basically I'm trying to just change the value of lat and lng in the position array but I can't seem to find a solution.
$('#data').find('div[name=postalCode]').each(function(i) {
var latlng = $(this).find('input[type=hidden]');
position.push(new google.maps.LatLng(latlng[0].value, latlng[1].value));
});
And this is how the position array is filled up.
Any help is appreciated. thanks Realize that the above comparison code does not fully compare, i'll put the new code here just in case anyone uses it
for (var i = 0; i < position.length; i++) {
for(var k = i+1; k<position.length; k++){
if (position[i].lat() == position[k].lat() && (position[i].lng() == position[k].lng())) {
console.log("before change" + i + position[i].lat());
position[i] = new google.maps.LatLng(
position[i].lat() + ((Math.random() * 1.5) / 100),
position[i].lng() + ((Math.random() * 1.5) / 100)
);
console.log("after change" +i + position[i].lat());
}
}
}
latandlnga property or function on your array? You're calling them both ways.()at the end oflatandlng.lat()means you are calling a function. but it is not a function. Remove the()