0

ジオコーディングされたイベントに基づいてポイントをレンダリングするGoogleFusionTableからポイントを表示しようとしています。イベントはマップを中央に配置し、マーカーを表示しますが、新しいマップの中心と固定半径に基づいて、テーブル上で新しい選択を行うようにしたいと思います。私の試みは変数を空間クエリに渡すことですが、それをどこに置くか、またはそれを正しく呼び出しているかどうかがわかりません。

さらに言えば、onClickイベントを使用して新しいクエリをトリガーするだけでもかまいませんが、同じ問題です。

よろしくお願いします...ラファ

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 

<title>Selected Records from Google Fusion Table based on Geocoded Location</title> 

<style>
  body { font-family: Arial, sans-serif; }
  #map_canvas { height: 600px; width:700px; }
</style>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript"> 

var layer;
var geocoder;
var map;
var tableid = 411675;

// initialize the map =====================
function initialize() {

    geocoder = new google.maps.Geocoder();  
  var latlng = new google.maps.LatLng(45.526, -122.6684);
    var myOptions = {
          zoom: 8,
          center: latlng,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
    map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
  layer = new google.maps.FusionTablesLayer(tableid);
  layer.setMap(map);    
}

// operates geocoder =====================
function codeAddress() {
    var gcAddress = document.getElementById("gcAddress").value;
    geocoder.geocode( { 'address': gcAddress}, 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
        });
                layer.setQuery("SELECT Address FROM " + tableid + " WHERE ST_INTERSECTS(Address, CIRCLE(LATLNG(" + position + "), 5000))");
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
}
</script> 
</head> 

<body onload="initialize();"> 
  <div> 
        <input id="gcAddress" type="textbox" value="Hillsboro, OR"> 
        <input type="button" value="Geocode" onclick="codeAddress()">
    </div>
    <div id="map_canvas"></div>
</body>
4

1 に答える 1

0

少し表情が間違っていたのではないかと思います。

var query = "SELECT Address FROM " + tableid + " WHERE ST_INTERSECTS(Address, CIRCLE(LATLNG" + marker.position + ", 20000))";

私はmarker.positionを読み取るように位置を更新し、それ自体に付属している括弧を削除しました。次に、テストのために半径を20000に拡張しました。

これは私のために働いた。クエリをテストする必要がある場合は、次のような例を使用できます。

http://kh-samples.googlecode.com/svn/trunk/talks/samples/fusiontableslayer.html

テストの基礎として(テーブル用に保存して変更するだけです)、うまくいけばバンドルに役立ちます:)

お役に立てれば。

マット

于 2011-01-31T10:15:52.647 に答える