I have this function
// add history paths and save data
function AddPath( strTag, strUserName, arrayLatLngPoints, pathColour) {
for (var i = 0; i < arrayLatLngPoints.length; i++)
{
var point = arrayLatLngPoints[i];
var date = new Date( parseInt( point.timestamp));
addMarkers(point.timestamp, point.lat, point.lng, point.timestamp, strUserName, pathColour, date.toString());
date = null;
}
}
as well as adding the markers with addMarkers() i want to store the lat, long and timestamp in an object.
I was thinking the best way to store would be like this
{ strUserName : { timestamp : point.timestamp , LatLng : point.LatLng }, strUserName : { timestamp : point.timestamp , LatLng : point.LatLng } }
or
{ strUserName : { timestamp : point.timestamp , LatLng : { lat : point.lat, lng : point.lng } }, ..
How can i create this object?
UPDATE:
Thanks for the replies. I have tried the following..
// add history paths and save data
function AddPath( strTag, strUserName, arrayLatLngPoints, pathColour) {
for (var i = 0; i < arrayLatLngPoints.length; i++)
{
var point = arrayLatLngPoints[i];
var pos = new google.maps.LatLng(point.lat, point.lng);
var history = {
strUserName : {
timestamp : point.timestamp ,
LatLng : pos
}
};
var date = new Date( parseInt( point.timestamp));
addMarkers(point.timestamp, point.lat, point.lng, point.timestamp, strUserName, pathColour, date.toString());
date = null;
}
console.log(history);
}
see screenshot of console

the username has not worked and im not getting an item for each timestamp, its just overwriting the one entry?