Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8179775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:04:25+00:00 2026-06-07T00:04:25+00:00

I have this function // add history paths and save data function AddPath( strTag,

  • 0

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
screenshot

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:04:27+00:00Added an answer on June 7, 2026 at 12:04 am

    How can i create this object?

    Pretty much exactly like you did:

    var obj = { strUserName : { timestamp : point.timestamp , LatLng : point.LatLng }, strUserName : { timestamp : point.timestamp , LatLng : point.LatLng } };
    

    Or more readably:

    var obj = {
        strUserName : {
            timestamp : point.timestamp ,
            LatLng : point.LatLng
        },
        strUserName : {
            timestamp : point.timestamp ,
            LatLng : point.LatLng
        }
    };
    

    That’s an object initializer. It creates a new object with the given properties (actually, three new objects) and returns a reference to the outermost of them.

    Taking some simpler examples:

    // Create a blank object (an object with no properties of its own):
    var a = {};
    
    // Create an object with a `name` property with the value "Fred"
    var b = {name: "Fred"};
    
    // Create an object with a `foo` property, which is *another* freshly-created
    // object with a `name` property with the value "Barney"
    var c = {
        foo: {
            name: "Barney"
        }
    };
    

    Re your updated question:

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

    Of course it is, you’re overwriting history on each loop, without storing the earlier copy anywhere. For instance, you can store them in an array:

    // add history paths and save data
    function AddPath( strTag, strUserName, arrayLatLngPoints, pathColour) {
    
      var historyArray = [];
      for (var i = 0; i < arrayLatLngPoints.length; i++)
        {
        var point = arrayLatLngPoints[i];
        var pos = new google.maps.LatLng(point.lat, point.lng);
    
        historyArray[i] = {
            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(historyArray);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a function for deleting object preiodically. function add(variable, expireSecond){ this.list[variable] =
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
Suppose I have this function saved in a certain script: function Add(a,b:integer):integer; begin result:=a+b;
I have this function: function start-sqlsnap { add-pssnapin SqlServerCmdletSnapin100 } Regardless of the method
I have this source code: var Game = function() { var canvas = document.getElementById('world');
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
I have this function: public bool IsValidProduct(int productTypeId) { bool isValid = false; if
I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target
I have this function on my controller (Im using CodeIgniter) that reads the database,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.