2011-01-29 2 views
0

지오 코딩 된 이벤트를 기반으로 Google 퓨전 테이블을 렌더링하는 포인트를 표시하려고합니다. 이벤트는지도를 중심에두고 마커를 표시하지만 새로운지도 중심과 고정 된 반지름을 기반으로 테이블에서 새로운 선택을하고 싶습니다. 필자의 시도는 공간 쿼리에 변수를 전달하는 것이지만 어디에 넣을 것인지, 아니면 내가 올바르게 호출 할 것인지 확신 할 수 없다.Google Fusion Tables에서 SQL expr의 LatLng 위치 변수 사용

새 쿼리를 실행하기 위해 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> 

답변

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

을 사용할 수 있습니다 희망 번들 :

희망 도움이 될 것입니다 이것은 도움이됩니다.

매트

+0

하! 아름다운. 그거야. 새 사이트는 나에게 멋진 아이디어를 제공합니다. 엄청 고마워! – geografa