【问题标题】:Setting Center Point in Google Search在 Google 搜索中设置中心点
【发布时间】:2013-06-03 15:59:18
【问题描述】:

我正在尝试学习如何使用 Google 本地搜索 API。我无法将本地搜索中心点设置为 巴基斯坦。请指导我。谢谢。

有问题的代码行是:

localSearch.setCenterPoint("Pakistan, PAK");

显示来自纽约的结果的小提琴是here

整个代码是,

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Hello World - Google  Web Search API Sample</title>
    <script src="https://www.google.com/jsapi"
        type="text/javascript"></script>
    <script language="Javascript" type="text/javascript">
    //<!

    //google.load('search', '1');
    google.load("search", "1", {"nocss" : true});

    function OnLoad() {
      // Create a search control
      var searchControl = new google.search.SearchControl();

      // Add in a full set of searchers
      var localSearch = new google.search.LocalSearch();

      searchControl.addSearcher(new google.search.NewsSearch());

      // Set the Local Search center point
      localSearch.setCenterPoint("Pakistan, PAK");

      // tell the searcher to draw itself and tell it where to attach
      searchControl.draw(document.getElementById("searchcontrol"));

      // execute an inital search
      searchControl.execute("Facebook");
    }
    google.setOnLoadCallback(OnLoad);

    //]]>
    </script>
  </head>
  <body>
    <div id="searchcontrol">Loading</div>
  </body>
</html>

【问题讨论】:

    标签: search google-search-api google-local-search


    【解决方案1】:

    相信你需要知道PAK的经纬度是多少才能找到它。

    setCenter(latlng:LatLng);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-27
      • 1970-01-01
      • 1970-01-01
      • 2016-03-15
      • 1970-01-01
      • 2012-08-29
      • 2021-12-06
      • 1970-01-01
      相关资源
      最近更新 更多