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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:17:49+00:00 2026-05-27T08:17:49+00:00

Json: [{latitude:42.658673,longitude:-73.810479,place:Bethany Reformed Church}] Full function: google.load(visualization, 1, {packages:[map]}); $(function() { // when document

  • 0

Json:
[{"latitude":"42.658673","longitude":"-73.810479","place":"Bethany Reformed Church"}]

Full function:
google.load("visualization", "1", {packages:["map"]});

    $(function() {
     // when document loads, grab the json
     $.getJSON('places.json', function(data) {
         // once grabbed, we run this callback

         // setup the new map and its variables
         var meetings = new google.visualization.DataTable();
             meetings.addRows(data.length);  // length gives us the number of results in our returned data
             meetings.addColumn('number', 'latitude');
             meetings.addColumn('number', 'longitude');
             meetings.addColumn('string', 'place');

         // now we need to build the map data, loop over each result
         $.each(data, function(i,v) {
             // set the values for both the location and place
             alert(i + ":" + v.latitude + ":" + v.longitude + ":" + v.place);
             // The alert displays the correct values
             meetings.setValue(i, 0, v.latitude);
             meetings.setValue(i, 1, v.longitude);
             meetings.setValue(i, 2, v.place);
             //the code stalls and nothing else gets executed
         });
         // finally, create the map!
         var map = new google.visualization.Map(document.getElementById('map_div'));
         map.draw(meetings, {showTip: true, mapType: 'normal'});

     });
   });

If I alert() the json values inside the $.each, they are correct, but the code stalls when the json values are in meetings.setValue(). I came to this conclusion because if I put an alert after the meetings.setValues, nothing pops up.

Output of alert:

0:42.658673:-73.810479:Bethany Reformed Church

If I hard code the actual locations in meetings.setValue(), it maps the location correctly.

Like this:

$.each(data, function(i,v) {
             // this maps the location correctly
             meetings.setValue(i, 0, 42.658673);
             meetings.setValue(i, 1, -73.810479);
             meetings.setValue(i, 2, 'Bethany Reformed Church');
 });

Why does the code seem to stall in the $.each when the json variables are used?

I have been using this as a guide: Using jQuery, JSON and Google’s Visualization Geo API Together

  • 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-27T08:17:50+00:00Added an answer on May 27, 2026 at 8:17 am

    When you hardcode it you’re using numbers:

    setValue(i, 0, 42.658673);
    

    but your JSON has strings:

    "longitude":"-73.810479"
    

    So either try changing the JSON to send numbers:

    "longitude":-73.810479
    

    or convert the strings to numbers before you send them to setValue:

    meetings.setValue(i, 0, +v.latitude);
    meetings.setValue(i, 1, +v.longitude);
    

    The unary + will convert the string to a number. For a more explicit conversion, use the Number constructor (but called without new).

    meetings.setValue(i, 0, Number(v.latitude));
    meetings.setValue(i, 1, Number(v.longitude));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want the latitude and longitude of two street that cross from the Google
I do not manage to get the latitude, longitude from the following json (hold
I want to get longitude & latitude from a json. to do so i
I have a Json array that contains latitude and longitude coordinates. Here's a sample:
I have following JSON for sending request on server { name:Home, latitude:45.5037078163837, longitude:-122.622699737549, radius:240
My simple android application uses google places api to get the latitude and longitude
I am having issues with passing a longitude and latitude to the google directions
I get the Json from google. it has many details on many things but
How to parse this Json using Gson and display the Placetype _Name and Place
I need to get latitude and longitude to my android, it got many values

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.