Search in Fusion Tables and Zoom to results

前端 未结 1 878
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 05:58

Hi all here\'s my situation: http://www.tamrielma.ps/skyrim/

I\'ve added a search based on this well know example: https://developers.google.com/fusiontables/docs/sa

相关标签:
1条回答
  • 2020-12-12 06:29

    Interesting map. :-) I see you are already using the Google.visualization library for your autocompplete set up. I think that the same library (which uses FT JSONP API I believe) could be used to get the location values via a a callback, similar to your getData() callback. E.g.

    function changeQuery(value) {
     value = value.replace("'", "\\'");
     layerMarkers.setQuery("SELECT Location FROM "+ fusione +" WHERE Name = '" + value + "'");
    
     // ADDED, using same query as above
      var queryText = encodeURIComponent( "SELECT Location FROM "+ fusione +" WHERE Name = '" + value + "'");
      var query = new google.visualization.Query('http://www.google.com/fusiontables/gvizdata?tq='  + queryText);
      query.send(getLocationData);
    
    }
    // location may need parsing into LatLng object
    function getLocationData(response) {
        numRows = response.getDataTable().getNumberOfRows();
        if(numRows == 1){
              var loc_str = response.getDataTable().getValue(0, 0));
              var tmp = loc_str.split(" ");
              var lat = parseFloat(tmp[0]);
              var lng = parseFloat(tmp[1]);
              var zoom_level = 10;
              var location = new google.maps.LatLng(lat,lng);
              map.setCenter(location);
              map.setZoom(zoom_level);
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题