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 6831221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:42:44+00:00 2026-05-26T22:42:44+00:00

Am working on Google Maps, I have a problem in creating an array of

  • 0

Am working on Google Maps, I have a problem in creating an array of objects, and a variable holds it(array of objects) for later processing.

var lat=new Array("12.996188333333","12.988683333333","12.99156","13.092916666667");
var lng=new Array("77.58392","77.57781","78.579193333333","77.594161666667");
var latlng = [      new google.maps.LatLng( lat[0], lng[0] ) ,    
        new google.maps.LatLng( lat[1], lng[1]),     
        new google.maps.LatLng( lat[2], lng[2] ),      
        new google.maps.LatLng( lat[3],lng[3] )];

so, latlng holds objects in array.This is a case where array lat and array lng are declared(static).What if its dynamic,say i have the count, but how do i create a dynamic array of objects. I tried to loop it, but no results.Please help!!!

for(var i=0;i<3;i++)
{
var latlng=new Array();
latlng[i]= new google.maps.LatLng(lat[i],lng[i]);
}

console.log(latlng) gives me:
[undefined,undefined,undefined,{13.092916666667,77.594161666667}]

  • 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-05-26T22:42:44+00:00Added an answer on May 26, 2026 at 10:42 pm
    var lat = ["12.996188333333","12.988683333333","12.99156","13.092916666667"];
    var lng = ["77.58392","77.57781","78.579193333333","77.594161666667"];
    
    var latlng = [];
    
    for (var i = 0; i < lat.length; i++)
        latlng[i] = new google.maps.LatLng(lat[i], lng[i]);
    

    (assuming lat and lng have the same length).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem with Google Maps showing differently in IE and the
Greetings, Until now I have mostly been working with google maps v2. I am
I'm working with the google maps API and trying to stringify an array of
I'm brand new to working with the google maps api, and i've been stuck
I'm having this problem: I have two Google maps in one page, showing just
This is my first time working with the Google Maps API. I have a
I have multiple Google Maps on a single page. Scenario: Maps are working as
I've been having a problem with Google maps API v.3. I have my canvas
I just started working using Google Maps API yesterday, and trying to set up
I'm working with the google maps API, and testing a section which geocodes all

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.