2014-03-31 2 views
0

필자는 그것이 무엇인지 놓치기 때문에 마음을 잃어 버리는 것처럼 느낍니다. 말 그대로 단지 대체 한퓨전 테이블 검색 및 확대

<!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 name="viewport" content="initial-scale=1.0, user-scalable=no"> 
<meta charset="UTF-8"> 

<title>Fusion Tables Layer Example: Search and Zoom</title> 

<link href="/apis/fusiontables/docs/samples/style/default.css" 
    rel="stylesheet" type="text/css"> 
<script type="text/javascript" 
    src="http://maps.google.com/maps/api/js?sensor=false"></script> 

<script type="text/javascript"> 

    function initialize() { 
    var defaultCenter = new google.maps.LatLng(10, 10); 
    var defaultZoom = 2; 
    var tableId = '1ZU8D1ASYZMeIise2gboBt-HPt9hX8Y2NIdMfZg'; 
    var locationColumn = 'lat'; 
    var geocoder = new google.maps.Geocoder(); 

    var map = new google.maps.Map(document.getElementById('map-canvas'), { 
     center: defaultCenter, 
     zoom: defaultZoom, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }); 

    var layer = new google.maps.FusionTablesLayer({ 
     query: { 
     select: locationColumn, 
     from: tableId 
     }, 
     map: map 
    }); 

    var zoomToAddress = function() { 
     var address = document.getElementById('address').value; 
     geocoder.geocode({ 
     address: address 
     }, function(results, status) { 
     if (status == google.maps.GeocoderStatus.OK) { 
      map.setCenter(results[0].geometry.location); 
      map.setZoom(10); 

      // OPTIONAL: run spatial query to find results within bounds. 
      var sw = map.getBounds().getSouthWest(); 
      var ne = map.getBounds().getNorthEast(); 
      var where = 'ST_INTERSECTS(' + locationColumn + 
       ', RECTANGLE(LATLNG' + sw + ', LATLNG' + ne + '))'; 
      layer.setOptions({ 
      query: { 
       select: locationColumn, 
       from: tableId, 
       where: where 
      } 
      }); 
     } else { 
      window.alert('Address could not be geocoded: ' + status); 
     } 
     }); 
    }; 

    google.maps.event.addDomListener(document.getElementById('search'), 
      'click', zoomToAddress); 
     google.maps.event.addDomListener(window, 'keypress', function(e) { 
      if (e.keyCode == 13) { 
      zoomToAddress(); 
      } 
     }); 
     google.maps.event.addDomListener(document.getElementById('reset'), 
      'click', function() { 
       map.setCenter(defaultCenter); 
       map.setZoom(defaultZoom); 
       layer.setOptions({ 
       query: { 
        select: locationColumn, 
        from: tableId 
       } 
       }); 
      }); 
     } 

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

    </script> 
    </head> 
    <body> 
    <div id="map-canvas"></div> 
    <div> 
     <label>Enter an address:</label> 
     <input type="text" id="address" value="Mountain View, CA"> 
     <input type="button" id="search" value="Search!"> 
     <input type="button" id="reset" value="Reset"> 
    </div> 
    </body> 
</html> 

:

나는 1IYJMddMoWgwjieq3rwh8YyiHVpZy_1--hoNrPPa2

주어진 코드는 퓨전 테이블의 ID에 해당 페이지에 https://developers.google.com/fusiontables/docs/samples/search_and_zoom 동일한 방식에서 사용 된 예제를 복제하는 것을 시도하고있다

var defaultCenter = new google.maps.LatLng(10, 10); 
var defaultZoom = 2; 
var tableId = '1ZU8D1ASYZMeIise2gboBt-HPt9hX8Y2NIdMfZg'; 
var locationColumn = 'lat'; 

과 :

var defaultCenter = new google.maps.LatLng(-33.927758210970154, 150.95845901699215); 
var defaultZoom = 10; 
var tableId = '1IYJMddMoWgwjieq3rwh8YyiHVpZy_1--hoNrPPa2'; 
var locationColumn = 'col3'; 

내가 이여 ght 그것은 그 다음 단지 일할 것이다. 그러나지도 자체는 전시하지 않을 것이다. 그런 다음 예제 코드를 사용하여 변경하지 않고 테스트한다고 생각했지만 작동하지는 않습니다.

내가 무엇을 놓쳤습니다! Ive가 잘못한 것에 완전히 단서 있습니다.

+0

의 중복 가능성 [내가 함께 FusionTablesLayer의를 사용하여 빈 페이지 구글지도 자바 스크립트 API v3의 (http://stackoverflow.com/questions/12789004/blank-page-를 통해 스타일 시트를로드 when-i-use-fusiontableslayer-google-maps-javascript-api-v3) – geocodezip

답변