Skip to content Skip to sidebar Skip to footer

Parsing Json From Google Map

I want to display place details from this json: I have problem with parse it, i want to get 'website', 'name' and 'rating'. This is a link to json: https://maps.googleapis.com/maps

Solution 1:

replace:

 $.each(data, function(entryIndex, entry) {
     var html = '<div class="entry">';
     html += '<h3 class="term">' + entry['name'] + '</h3>';
     html += '<div class="part">' + entry['website'] + '</div>';
     html += '<div class="definition">';
     html += entry['rating'];
     html += '</div>';
     html += '</div>';
     $('#dictionary').append(html);
  });

with:

var html = '<div class="entry">';
     html += '<h3 class="term">' + data.result['name'] + '</h3>';
     html += '<div class="part">' + data.result['website'] + '</div>';
     html += '<div class="definition">';
     html += entry['rating'];
     html += '</div>';
     html += '</div>';
     $('#dictionary').append(html);

The each is not needed. Access the data directly with data.result.name, since data is a single object as well as result

Post a Comment for "Parsing Json From Google Map"