0

I am trying to learn how to use Google Local Search API. I am unable to set the local search center point to Pakistan. Please guide me. Thanks.

The line in code with the problem is:

localSearch.setCenterPoint("Pakistan, PAK");

The fiddle showing that results from NewYork are being displayed is here.

The whole code is,

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

1 Answers1

0

I believe you need to know what the latitude and longitude of PAK is for it to find it.

setCenter(latlng:LatLng);

Saucy
  • 26
  • 2