在 Fusion Tables 中搜索并缩放到结果 [英] Search in Fusion Tables and Zoom to results

查看:25
本文介绍了在 Fusion Tables 中搜索并缩放到结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,这是我的情况:http://www.tamrielma.ps/skyrim/

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

我根据这个众所周知的例子添加了一个搜索:https://developers.google.com/fusiontables/docs/samples/autocomplete但这还不够 :D 并且我希望地图根据搜索结果进行缩放和居中(这是单个标记而不是一组标记,所以我认为这不是绑定相关"解决方案).

I've added a search based on this well know example: https://developers.google.com/fusiontables/docs/samples/autocomplete But it's not enough :D and I want that the map zooms and centers on the basis of the search results (that's a single markers not a group of, so I imagine that's not a "bound related" solution).

预先感谢您的任何建议

推荐答案

有趣的地图.:-) 我看到您已经在使用 Google.visualization 库进行自动完成设置.我认为可以使用同一个库(我相信它使用 FT JSONP API)通过回调获取位置值,类似于你的 getData() 回调.例如

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);
    }

}

这篇关于在 Fusion Tables 中搜索并缩放到结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆