title: Using Json to add markers to Google Maps | API
body: <p>I'm trying to plot markers on a google map using data from a Json Response. I have searched Stack Overflow for an answer all day but havn't managed to find a solution that has worked for me.</p>
  
  <p>I'm guessing it has something to do with the way I am extracting the Lat &amp; Lng but just can't put my finger on it. Below are my code and the Json, the Json is from an API.</p>
  
  <p>Where is the error in my code?</p>
  
  <h2>Script</h2>
  
  <pre><code>&lt;script&gt;   
    function initialize() {
                var myOptions = {
                    zoom: 4,
                    center: new google.maps.LatLng(34.397, 150.644),
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
  
                map = new google.maps.Map(document.getElementById("map"), myOptions);
                };
  
    function getLocations() {
  
        $.getJSON("URL", function (json) {
  
            $.each(json["resultsPage"]["results"]["event"], function(i, entry){
                addMarker(entry.location.lat,entry.location.lng);
            });
        });
    }
  
    function addMarker(lat,lng) {
            marker = new google.maps.Marker({
            position: new google.maps.LatLng(lat,lng),
            map: map,
            });
            markersArray.push(marker);
    }
    &lt;/script&gt;
  </code></pre>
  
  <h2>Json Response</h2>
  
  <p>Told to request Json data by using the following code. If I leave the question mark at the end I get an invalid message when I run it through <a href="http://jsonlint.com" rel="noreferrer">http://jsonlint.com</a> as there is a question mark at the beginning of the Json. Taking that out appears to solve the problem but I'm not 100% sure that that is ok?</p>
  
  <pre><code>    $.getJSON("http://api.songkick.com/api/3.0/events.json?location=clientip&amp;apikey={your_api_key}&amp;jsoncallback=?",
      function(data){
      // data is JSON response object
      });
  </code></pre>
  
  <p>If I leave the question mark at the end I get an invalid message when I run it through <a href="http://jsonlint.com" rel="noreferrer">http://jsonlint.com</a> as there is a question mark at the beginning of the Json. Taking that out appears to solve the problem but I'm not 100% sure that that is ok?</p>
  
  <p>When I view the code in debugger I get " SyntaxError: Unexpected token ':' ", but this response is coming from an API so I am unsure what I can do about it?</p>
  
  <pre><code>    {
      "resultsPage": {
      "status": "ok",
      "results": {
          "event": [
              {
                  "type": "Concert",
                  "status": "ok",
                  "performance": [
                      {
                          "artist": {
                              "displayName": "Arcade Fire",
                              "uri": "http://www.songkick.com/artists/66758-arcade-fire?utm_source=16289&amp;utm_medium=partner",
                              "identifier": [
                                  {
                                      "mbid": "52074ba6-e495-4ef3-9bb4-0703888a9f68",
                                      "href": "http://api.songkick.com/api/3.0/artists/mbid:52074ba6-e495-4ef3-9bb4-0703888a9f68.json"
                                  }
                              ],
                              "id": 66758
                          },
                          "billingIndex": 1,
                          "billing": "headline",
                          "displayName": "Arcade Fire",
                          "id": 29913729
                      },
                      {
                          "artist": {
                              "displayName": "Doody and Kami",
                              "uri": "http://www.songkick.com/artists/6334389-doody-and-kami?utm_source=16289&amp;utm_medium=partner",
                              "identifier": [],
                              "id": 6334389
                          },
                          "billingIndex": 2,
                          "billing": "support",
                          "displayName": "Doody and Kami",
                          "id": 29913734
                      },
                      {
                          "artist": {
                              "displayName": "Leah Gordon",
                              "uri": "http://www.songkick.com/artists/6334394-leah-gordon?utm_source=16289&amp;utm_medium=partner",
                              "identifier": [],
                              "id": 6334394
                          },
                          "billingIndex": 3,
                          "billing": "support",
                          "displayName": "Leah Gordon",
                          "id": 29913739
                      }
                  ],
                  "venue": {
                      "metroArea": {
                          "country": {
                              "displayName": "Canada"
                          },
                          "state": {
                              "displayName": "QC"
                          },
                          "displayName": "Montreal",
                          "uri": "http://www.songkick.com/metro_areas/27377-canada-montreal?utm_source=16289&amp;utm_medium=partner",
                          "id": 27377
                      },
                      "lat": 45.5014288,
                      "displayName": "Phi Center",
                      "lng": -73.5564459,
                      "uri": "http://www.songkick.com/venues/1973969-phi-center?utm_source=16289&amp;utm_medium=partner",
                      "id": 1973969
                  },
                  "popularity": 0,
                  "location": {
                      "lat": 45.5014288,
                      "lng": -73.5564459,
                      "city": "Montreal, QC, Canada"
                  },
                  "start": {
                      "time": null,
                      "date": "2013-02-23",
                      "datetime": null
                  },
                  "displayName": "Arcade Fire with Doody and Kami and Leah Gordon at Phi Center (February 23, 2013)",
                  "uri": "http://www.songkick.com/concerts/15215934-arcade-fire-at-phi-center?utm_source=16289&amp;utm_medium=partner",
                  "id": 15215934
              }
          ]
      },
      "perPage": 50,
      "page": 1,
      "totalEntries": 1
      }
      }  
  </code></pre>
  
  <p>Any help would be greatly appreciated. Thanks</p>
  
  <h2>Updated</h2>