0

尝试使用以下代码访问合并的 Fusion Table 时出现 403 Forbidden 错误。我也不明白为什么也不知道如何解决这个问题。

访问已与另一个表合并的表就像一个魅力。

合并后的表和基表都可以公开下载。

有谁知道可能出了什么问题??访问合并表是否受到某种限制?

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="UTF-8">

    <title>FÖJ-Einsatzstellen</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        font-size: 12px;
      }

      #map-canvas {
        height: 500px;
        width: 600px;
      }
    </style>

    <script type="text/javascript"
        src="https://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript"
      src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
    </script>

    <script type="text/javascript">

      var map;
      var infoWindow = new google.maps.InfoWindow();
      var DEFAULT_ICON_URL = 'http://g.etfv.co/http://www.google.com'

      // EDIT: change this key to your own from the Google APIs Console
      // https://code.google.com/apis/console/
      var apiKey = 'PLACE_YOUR_OWN_KEY_HERE';

      // EDIT: Specify the table with location data and icon URLs
      //var tableID = '1i0mw7f4b06sG14-mAO-zEJI1gekZ8wte_J6w05c'; // Basis-Table
      var tableID = '1eCPADfnXccPMAYh24W-pUEF-eiKSlOD9e0xSKBM'; // ge-merge-te Table

      // Create variables for the columns you need to retrieve from the table
      var latitudeColumn = 'Latitude';
      var iconUrlColumn = 'Farbcodierung für Marker';

      function createMarker (coordinate, url, content) {
          var marker = new google.maps.Marker({
            map: map,
            position: coordinate,
            icon: new google.maps.MarkerImage(url)
          });
          google.maps.event.addListener(marker, 'click', function(event) {
            infoWindow.setPosition(coordinate);
            infoWindow.setContent(content);
            infoWindow.open(map);
          });
        };

      function fetchData() {
        // Construct a query to get data from the Fusion Table
        var query = 'SELECT '
                    + latitudeColumn + ','
                    + '\'' + iconUrlColumn + '\''
                    + ' FROM '
                    + tableID;
        var encodedQuery = encodeURIComponent(query);

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

        // Send the JSONP request using jQuery
          $.ajax({
            url: url.join(''),
            dataType: 'jsonp',
            success: onDataFetched,
            error: onError,
            timeout : 7500
          });
      }

      function onError(e) {
        alert(e);
      }

      function onDataFetched(data) {
        if(data.error) {
            var errs = data.error.errors;
            var msg = "";
            for (var i in data.error.errors) {
                msg += 
                parseInt(i, 10)+1 + ". Fehler:" + 
                "\ndomain: " + errs[i].domain +
                "\nmessage: " + errs[i].message +
                "\nreason: " + errs[i].reason + "\n";
            }
            alert(
                "Leider sind Fehler aufgetreten (um genau zu sein: " + data.error.errors.length + " Fehler, Code: " + data.error.code + "):\n" + msg
            );
            return;
        }
        var rows = data['rows'];
        var iconUrl;
        var iconUrl_part1 = 'http://chart.apis.google.com/chart?cht=mm&chs=32x32&chco=';
        var iconUrl_part2 = '&ext=.png';
        var content = "mein content";
        var coordinate;

        // Copy each row of data from the response into variables.
        // Each column is present in the order listed in the query.
        // Starting from 0.
        // EDIT this if you've changed the columns, above.
        for (var i in rows) {
          var geocode = rows[i][0].split(",");
          coordinate = new google.maps.LatLng(geocode[0],geocode[1]);

          if (rows[i][1] != '') {   // ensure not empty
            iconUrl = iconUrl_part1 + rows[i][1] + iconUrl_part2;
            createMarker(coordinate, iconUrl, content);
          } else {
            createMarker(coordinate, DEFAULT_ICON_URL, content);
          }
        }
      }

      function initialize() {
        fetchData();  // begin retrieving data from table, and put it on the map

        map = new google.maps.Map(document.getElementById('map-canvas'), {
          center: new google.maps.LatLng(48.537778, 9.041111),
          zoom: 7,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        });
      }

      google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="map-canvas"></div>
  </body>
</html>
4

0 回答 0