使用 Javascript 从 Google 融合 table 中的 kml 字段中提取纬度和经度

Using Javascript to extract the Latitude and Longitude from a kml field in a Google fusion table

我有一个 google 融合 table,我正在向其中插入包含 kml 的数据。 我需要从 kml 列中查询(或提取)纬度和经度。 当我查询 table 时,我得到以这种格式返回的数据:

{
"kind": "fusiontables#sqlresponse",
"columns": [
"description",
"name",
"geometry"
],
"rows": [
  [
 "\u003cimg alt=\"The North Fields\" class=\" tall\" src=\"https://d15mj6e6qmt1na.cloudfront.net/files/images/1501/0978/The_North_Fields_small.JPG\" style=\"float:left; padding: 0 3px 3px\" /\u003e\n            by ctipp\u003cbr/\u003e\n            \u003ca href=\"http://audioboom.com/boos/3260713-coastal-lagoon\"\u003eVisit on audioboom.com\u003c/a\u003e\n            \u003chr style=\"clear:both\"/\u003e",
 "Coastal Lagoon",
 {
  "geometry": {
 "type": "Point",
 "coordinates": [
  -0.749484,
  50.7627,
  0.0
 ]
}
}
]
]
}

使用回调函数将上述数据读入 javascript 变量,我需要知道提取经纬度的正确语法(即 -0.749484、50.7627)

我已经做到了:

success: function(data) {
        var rows = data['rows'];
        var desc = rows[0][0];
        var name = rows[0][1];

但我卡在了几何领域...

success: function(data) {
  var rows = data['rows'];
  var desc = rows[0][0];
  var name = rows[0][1];
  var latitude = rows[0][2].geometry.coordinates[1]; // KML is longitude, latitude
  var longitude = rows[0][2].geometry.coordinates[0];

var data = {
  "kind": "fusiontables#sqlresponse",
  "columns": [
    "description",
    "name",
    "geometry"
  ],
  "rows": [
    [
      "\u003cimg alt=\"The North Fields\" class=\" tall\" src=\"https://d15mj6e6qmt1na.cloudfront.net/files/images/1501/0978/The_North_Fields_small.JPG\" style=\"float:left; padding: 0 3px 3px\" /\u003e\n            by ctipp\u003cbr/\u003e\n            \u003ca href=\"http://audioboom.com/boos/3260713-coastal-lagoon\"\u003eVisit on audioboom.com\u003c/a\u003e\n            \u003chr style=\"clear:both\"/\u003e",
      "Coastal Lagoon", {
        "geometry": {
          "type": "Point",
          "coordinates": [-0.749484,50.7627,0.0]
        }
      }
    ]
  ]
};

function initialize() {
  var infowindow = new google.maps.InfoWindow();
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 16,
    center: {
      lat: 50.7627,
      lng: -0.749484
    }
  });
  var latLng = new google.maps.LatLng(data.rows[0][2].geometry.coordinates[1],
    data.rows[0][2].geometry.coordinates[0]);
  var marker = new google.maps.Marker({
    position: latLng,
    map: map
  });
  google.maps.event.addListener(marker, 'click', function(evt) {
    infowindow.setContent("name: " + data.rows[0][1] + "<br>desc: " + data.rows[0][0]);
    infowindow.open(map, marker);
  });
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#map {
  height: 100%;
  width: 100%;
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>