1

我想在我的项目中使用谷歌 API。我得到的api来自这里

APi 是:- https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=5000&types=food&sensor=false&key= * ** * ** * ** * ** * ** * ***

注意:- 我已在此 URL 的末尾附加了我的 KEY。它向我展示了正确的反应。但是,如果我将纬度和经度更改为古吉拉特邦(印度国家)..那么它不会向我显示任何响应。如果 ZERO_RESULT 则响应

谁能帮助我为什么会发生以及如何解决它。

我这样做是为了获取当前经纬度的附近信息..有没有其他方法或api来获取附近区域的信息..请帮助我..提前谢谢

4

2 回答 2

1

如果地图上在给定半径的给定坐标(纬度和经度)周围没有注册位置,则 API 将响应 ZERO_RESULT

得到结果

  • 指定正确的坐标(当前位置)
  • 半径限制,最大允许半径为 50000 米 = 50 KM

以下网址有效 - 提供距古吉拉特邦 30 公里范围内的食物类型地点(给定坐标)。

https://maps.googleapis.com/maps/api/place/search/json?location=23.0,72.0&radius=30000&types=food&sensor=false&key= [API 密钥]

于 2013-04-15T11:57:18.417 回答
1

我使用了这个片段,它适用于每种情况。

<body>
<div id="mainpanel" style="float:left; background-color:#fff; width:75%;">
    <div style="display:none;" id="lat">hhh</div><div style="display:none;" id="lon">hhh</div>


<script>
var x=document.getElementById("lat");
var y=document.getElementById("lon");
function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition);
    }
  else{x.innerHTML="Geolocation is not supported by this browser.";}
  }
function showPosition(position)
  {
  x.innerHTML=position.coords.latitude; 
  y.innerHTML=position.coords.longitude;
  loadScript();
  }

function initialize()
{
var xval=document.getElementById("lat").innerHTML;
var yval=document.getElementById("lon").innerHTML;
var mapProp = {
   center: new google.maps.LatLng(xval,yval),
    zoom:7,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

function loadScript()
{
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false&callback=initialize";
  document.body.appendChild(script);
}
//window.onload = loadScript;
</script>
    <form>
        <input class="boxinput" type="text" class="form-control" placeholder="Phone" id="" name=""/>
        </form>
    <div class="serchbox"></div>
    <div id="googleMap" style="width:960px;height:804px;"></div>

    </div>  
     </body>
于 2014-05-08T06:00:50.083 回答