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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:50:35+00:00 2026-06-03T19:50:35+00:00

I am quite new to programming, so I’m a little scared to post. But

  • 0

I am quite new to programming, so I’m a little scared to post. But I’ve been working on something that’s likely quite simple for most of you for two days and thought I’d try here…

I am trying to create markers in the Google Maps API.

If I hard code the data into javascript, like this, it works like a charm.

var locations = [
['1 Bedroom House', 55.1111, -100.1111, 1, 'This house has 1 bedroom.'],
['2 Bedroom House', 56.1111, -100.1111, 2, 'This house has 2 bedrooms.'],
['3 Bedroom House', 57.1111, -100.1111, 3, 'This house has 3 bedrooms.'],
['4 Bedroom House', 58.1111, -100.1111, 4, 'This house has 4 bedrooms.']
];

I have a JSON request and need to get the marker data from there instead.

Before you say it, I’m sure I’m WAY off on here… but this is what I got:

var locations = new Array();

$.getJSON("[URL]", function(json) {
        for(var i = 0; i < json.houses.length; i++) {
            var name = json.houses[i].house.name;
            var markerlat = json.houses[i].house.lat;
            var markerlng = json.houses[i].house.lng;
            var description = json.houses[i].house.description;

locations[i] = new Array();
locations[i].push('\'' + name + '\', ' + markerlat + ', ' + markerlng + ', ' + i + ', ' + '\'' + description + '\'');

}
});

Thanks!

  • 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-03T19:50:38+00:00Added an answer on June 3, 2026 at 7:50 pm

    By looking at that part of your code, I wonder if it could be solved without the separate locations array.

    Could it work if you extend the for loop in the success handler of the $.getJSON function with following kind of code:

    new google.maps.Marker({
        position: new google.maps.LatLng(markerlat, markerlng),
        title: name,
        map: [id of the map canvas element]
        });
    

    If you want to have the descriptions also available, you’ll have to attach listeners to the markers that trigger info windows. More details of the Info Window overlays and their usage can be found from Google Maps API documentation site.

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

Sidebar

Related Questions

I'm quite new to that functional programming paradigm, but so far I like it.
I'm quite new into the programming game, I've been working on this program for
I'm quite new to programming Google Earth with KML but I've been asked to
I'm quite new to Android programming but familiar with C/C++ and Linux enough to
I'm quite new in iPhone Programming, but I'm trying to do my best cause
I'm quite new to Scala programming language, and was trying something out stucked in
Probably a stupid question, but I'm quite new to the whole get-and-set-property-kind of programming;
I am quite new to programming, but now experimenting with a table view app.
I'm quite new to .NET programming. I know that .NET programming is 100% object
I am quite new to programming in Java, but I have some experience in

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.