0

基本的には、inputValue変数をfusionテーブルクエリに渡して、 'Name'カラムの値がinputValueに等しいジオメトリを検索します。GoogleマップApi Fusionテーブル名前が変数と等しい図形を選択

これはどのように記述する必要があるかを知る必要があります。どんな助けでも大歓迎です。以下のコード:

jQuery(document).ready(function($) { 

// function init() { 

var baseLatLng = new google.maps.LatLng(52.7713,-1.5550); 
var newLatLng; 

var map = new google.maps.Map(document.getElementById('map'), { 
    zoom: 12, 
    center: baseLatLng 
}); 

var searchOptions = { 
    center: baseLatLng, 
    mapTypeID: 'roadmap', 
    componentRestrictions: {country: "uk"} 
}; 

var input = document.getElementById('search'); 

var autocomplete = new google.maps.places.Autocomplete(input, searchOptions); 

var inputValue = document.getElementById('search').value; 

var geocoder = new google.maps.Geocoder(); 

$("#go").click(function(event) { 
    event.preventDefault(); 
    geocodeAddress(geocoder); 
    layer.setMap(map); 

}); 


function geocodeAddress(geocoder) { 
    var address = document.getElementById('search').value; 
    geocoder.geocode({address: address, region: 'uk'}, function(results, status) { 
     if (status === 'OK') { 
     } else { 
      alert('Geocode was not successful for the following reason: ' + status); 
     } 
     var latitude = results[0].geometry.location.lat(); 
     var longitude = results[0].geometry.location.lng() 
     newLatLng = latitude + ',' + longitude; 
     document.getElementById('results').innerHTML = "latitude:" + latitude + "<br>" + "longitude:" + longitude; 

    }); 
} 

var layer = new google.maps.FusionTablesLayer({ 
    query: { 
     select: 'Geometry', 
     from: 'xxxx', 
     where: "'Name' = inputValue" ---HERE! 
    }, 
    styles: [{ 
     polygonOptions: { 
      fillColor: '#00FF00', 
      fillOpacity: 0.3 
     } 
    }] 
}); 
}); 

おかげで、解決策を考え出した Ollie第

+0

"名前"列の番号はタイプ番号です。 – geocodezip

+0

私は次のような境界を選択できます: ": '' Name '=' Derbyshire '"しかし、郡を検索変数に置き換えたい –

+0

検索変数は列の名前と一致しません。 – geocodezip

答えて

0

。私はこれを今後誰かのために残しておきます。

function getBoundry() { 
     var address = document.getElementById('search').value; 
     var query = "\"\'Name\' = " + "\'" + address + "\'" + '\"'; 

     var layer = new google.maps.FusionTablesLayer({ 
      query: { 
       select: 'Geometry', 
       from: 'xxxxx', 
       where: query 
      }, 
      styles: [{ 
       polygonOptions: { 
        fillColor: '#00FF00', 
        fillOpacity: 0.3 
       } 

      }] 

     }); 
     layer.setMap(map); 
    } 

次に、funcitonがclickイベントで呼び出されます。

$("#go").click(function(event) { 
     event.preventDefault(); 
     getBoundry(); 

    }); 
関連する問題