The Google Fusion Tables API v1 has been deprecated as of May 3rd, 2016. The API will continue to work until August 1st, 2017, and will shut down on that date. A migration guide is available outlining the steps to take to migrate to v2.

Fusion Tables Layer Example: Basic JSONP Request

<!DOCTYPE html>
<!--
  Copyright 2011 Google Inc. All Rights Reserved.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<html>
  <head>
    <meta charset="UTF-8">
    <title>Fusion Tables Layer Example: Basic JSONP Request</title>
    <style type="text/css">
      #map-canvas {
        height: 500px;
        width: 600px;
      }

      .store-name {
        font-weight: bold;
        margin: 10px 0px 0px 0px;
        padding: 0px;
      }

      .address, .delivers {
        margin: 0px;
        padding: 0px;
      }
    </style>

    <script
        src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
    </script>
    <script type="text/javascript">
      function initialize() {
        var query = "SELECT 'Store Name', Address, delivery FROM " +
            '15UY2pgiz8sRkq37p2TaJd64U7M_2HDVqHT3Quw';
        var encodedQuery = encodeURIComponent(query);

        // Construct the URL
        var url = ['https://www.googleapis.com/fusiontables/v1/query'];
        url.push('?sql=' + encodedQuery);
        url.push('&key=AIzaSyAm9yWCV7JPCTHCJut8whOjARd7pwROFDQ');
        url.push('&callback=?');

        // Send the JSONP request using jQuery
        $.ajax({
          url: url.join(''),
          dataType: 'jsonp',
          success: function (data) {
            var rows = data['rows'];
            var ftData = document.getElementById('ft-data');
            for (var i in rows) {
              var store = rows[i][0];
              var address = rows[i][1];
              var delivers = rows[i][2];
              var dataElement = document.createElement('div');
              var storeElement = document.createElement('p');
              storeElement.innerHTML = store;
              storeElement.className = 'store-name';
              var addressElement = document.createElement('p');
              addressElement.innerHTML = address;
              addressElement.className = 'address';
              var deliversElement = document.createElement('p');
              deliversElement.innerHTML = 'Delivers? ' + delivers;
              deliversElement.className = 'delivers';

              dataElement.appendChild(storeElement);
              dataElement.appendChild(addressElement);
              dataElement.appendChild(deliversElement);
              ftData.appendChild(dataElement);
            }
          }
        });
      }
    </script>
  </head>
  <body onload="initialize()">
    <div id="ft-data"></div>
  </body>
</html>