使用google.maps.FusionTablesLayer时限制结果

时间:2015-03-19 17:51:33

标签: api google-maps maps google-fusion-tables

当我想限制它时,我的地图会显示融合表中的所有数据。

另外,我如何通过“地理名称”进行查询。领域?我尝试了下面的查询,但它不起作用。

***编辑我使用类似的代码解决了下面的问题:

select: 'State Abbr.',
    from: '1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa',
    where: "'State Abbr.' = 'FL'",

问题在于缺乏报价。

感谢任何帮助!

select: 'State-County',
from: '1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa',
where: 'State-County = AL-Autauga'

这是我目前的代码:

****编辑:我已通过更新代码修复了以下问题,如下所示

查询:{ 选择:' GEO_ID', 来自:' 1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa', 其中:" GEO_ID =' 05000US01001'"  },

<!DOCTYPE html>

<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Geocoding service</title>
    <style>
      html, body, #map-canvas {
        height: 100%;
        margin: 0px;
        padding: 0px
      }
      #panel {
        position: absolute;
        top: 5px;
        left: 50%;
        margin-left: -180px;
        z-index: 5;
        background-color: #fff;
        padding: 5px;
        border: 1px solid #999;
      }
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script>
    <script>

var geocoder;
var map;
var layer;

function initialize() {
  geocoder = new google.maps.Geocoder();
  var latlng = new google.maps.LatLng(34.0754, -84.2946);
  var mapOptions = {
    zoom: 8,
    center: latlng
  }
  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}

function codeAddress() {
  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);
      var marker = new google.maps.Marker({
          map: map,
          position: results[0].geometry.location
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }
  });

layer = new google.maps.FusionTablesLayer({

    query: {
    select: 'GEO_ID',
    from: '1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa',
    where: 'GEO_ID = 05000US01001'
     },
    supressInfoWindows: true,
    styles: [
            {polygonOptions: {fillColor:'#0040FF',fillOpacity:0.1,strokeColor:'#FF0000',strokeWeight:2,strokeOpacity:0.6    }}
      ]
  });
  layer.setMap(map);

}

google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="panel">
      <input id="address" type="textbox" value="Alpharetta, Georgia">
      <input type="button" value="Geocode" onclick="codeAddress()">
    </div>
      <div id="map-canvas"></div>
    </div>
  </body>
</html>

链接到Fusion Table:https://www.google.com/fusiontables/data?docid=1xdysxZ94uUFIit9eXmnw1fYc6VcQiXhceFd_CVKa#rows:id=3

0 个答案:

没有答案