Google Maps embed search not showing results?

Viewed 294

I am attempting to search for places within an area around a lat/lon coordinate using the Google Maps embed API. The code below displays the map correctly, but the search results it displays are for a different location. On one browser it thinks I'm in Rome Italy, and another near my actual location.

Is there a way to get the search results for the displayed area in the map?

<iframe 
  width="600" 
  height="450" 
  style="border:0" 
  allowfullscreen 
  src="https://www.google.com/maps/embed/v1/search?key=APIKEY&q=Restaurant&center=43.98444444,-88.55694444&zoom=14"> </iframe>
2 Answers

From the documentation:

search mode
Search mode displays results for a search across the visible map region. It's recommended that a location for the search be defined, either by including a location in the search term (record+stores+in+Seattle) or by including a center and zoom parameter to bound the search.

If I convert the center point of your map to an address (2982 Eide Rd, Oshkosh, WI 54902) and add that to the query, I get results showing on the map.

proof of concept fiddle

screen shot of resulting map

code snippet:

<iframe 
  width="600" 
  height="450" 
  style="border:0" 
  allowfullscreen 
  src="https://www.google.com/maps/embed/v1/search?q=Restaurants near 2982 Eide Rd, Oshkosh, WI 54902&center=43.98444444,-88.55694444&zoom=12&key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg"> </iframe>

Google map allow you to specify a region to avoid this kind of problem. Set the region of your map like this (UK in my exemple):

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&region=UK&callback=initMap" async defer></script>

Add region=YOUR_REGION_CODE just after you're API key when you initialize the google map script.

In you're exemple you can try something like :

https://www.google.com/maps/embed/v1/search?key=APIKEY&region=IT&q=Restaurant&center=43.98444444,-88.55694444&zoom=14"
Related