0

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

有问题的代码行是:

localSearch.setCenterPoint("Pakistan, PAK");

显示来自 NewYork 的结果的小提琴在这里

整个代码是,

<!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>
4

1 回答 1

0

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

setCenter(latlng:LatLng);

于 2013-06-03T16:13:34.847 回答