Query a JSON in Google Maps

Query a JSON in Google Maps

Hi

I have a Google maps page that is is working quite fine so far. I add a number of markers to the map using a function and a static JSON.

I would now like to replace the static JSON and query the data using jQuery/AJAX. I have tried various options, but somehow I keep getting the error, that the JSON is not defined. I feel I'm just missing a small thing.

Currently I create the markers using this function call, where planes is the static JSON holding the information regarding the markers:

  1. setPlanes(map, airborne);
  2.  
  3. airborne = [
    ["CRK", 35.440634, 113.294862, 1, "RCE 1161", 170, 520, "CIH-WUH", 30, 51, 7807466],
    ["CR7", 31.099633, 108.485886, 2, "RCE 5029", 92, 525, "DAX-WUH", 30, 51, 7807471],
    ["CRK", 29.405961, 111.095604, 3, "RCE 1179", 62, 453, "DYG-WUH", 30, 51, 7807472],
    ["CRK", 30.750464, 114.148327, 4, "RCE 1211", 57, 715, "JHG-WUH", 30, 51, 7807482]
    ];


Instead of having a static JSON I'm now trying to populate the content of the JSON using this function:


  1.         function getPlanes() {
            $.ajax({
                dataType: 'json',
                data: {},
                contentType: 'application/json; charset=utf-8',
                url: 'api/planes.asp?W=dev&C=449',
                success: function(data) {
                  if (data.status = 'success') {
                    airborne = data.message;
                  } else {
                    alert(data.message);
                  }
                },
                error: function() {
                  alert('Oops! Something went wrong.');
                }
              });
            }


When I call the URL manually, I do get a valid JSON according to JSONLint. It also looks exactly the same as the static JSON shown above. But I do get an error message saying that the JSON is undefined.

I also tried to call the above function like this:


  1. setPlanes(map, getPlanes());


But this didn't work either.

How do I write the Content back?