syam deth
syam deth

Reputation: 231

Google Map Api with key not working

Iam using google map for showing different peoples in different location. I already purchased Google Maps API key for Work customers. I added my key to the search like below.

$url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=".$_SESSION['userlat'].",".$_SESSION['userllong']."&sensor=false&key=XXXXXXXXXXXX-XXX";
$details=file_get_contents($url);       
$geocodedinfo = json_decode($details,true);

But sometimes i get a message OVER_QUERY_LIMIT and maps shows empty. But i won't use 100,000 requests per 24 hour period., 10 requests per second

AM I USING THE RIGHT FORMAT FOR ADDING API KEY

Now iam getting map like below. None of my users are not listing there. But sometimes its works fine. Thanks in advance

enter image description here

Upvotes: 1

Views: 144

Answers (1)

jogesh_pi
jogesh_pi

Reputation: 9782

OVER_QUERY_LIMIT seems like you are sending request file_get_contents($url) in a loop, Before 1 week i tackle with this issue by using Caching. But i didn't used KEY to fetch the latlng.

As you said But sometimes its works fine. Store the LatLng value in Cache and Apply on map by cached DATA.

I Used cacheing in WordPress, so its is also easy to update any latlng to me in wordpress.

If you are not familiar with cacheing then store it in a text file [In Well format so that its easy to fetch or compare].

Upvotes: 1

Related Questions