Reputation: 3473
I want to use google API in my project. The api i got is from here
And the APi IS :- https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=5000&types=food&sensor=false&key=*******************
NOTE:- I had appended my KEY at the end of this URL. It is showing me proper response. But if i change the latitude and longitude to Gujarat state ( country india) ..Then it is not showing me any response. And the response if ZERO_RESULT
Can anyone help me why it is happening and how to solve it.
I This is want to do this is to get the nearby information of current latitide-longitude.. Is there any other way or api to get the information of nearby area.. Please help me.. Thanks in advance
Upvotes: 1
Views: 702
Reputation: 86
I used this snippet and it works for every case.
<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>
Upvotes: 1
Reputation: 2225
If there is no register place on map around given coordinates(latitude & longitude) with given radius then API will responds ZERO_RESULT
To get result
Following url is working - Gives places of type food within 30 KM distance from Gujarat (given coordinates).
Upvotes: 1