serpapi / public-roadmap

Public Roadmap for SerpApi, LLC (https://serpapi.com)
45 stars 3 forks source link

[Google Maps API] `type=place` search returns no results with a valid `data` parameter #1625

Closed martin-serpapi closed 1 month ago

martin-serpapi commented 1 month ago

A customer reported that our Google Maps API does not return results when they use a data parameter extracted directly from the URL in the Google Maps engine. I was able to reproduce it.

Executing a request using our Google Maps API with the data parameter provided by the customer - !4m16!1m9!3m8!1s0x46b54bd53dd429dd:0xf026259b7dbd3925!2z0KDQvtGB0LPQtdC-0LvQvtCz0LjRjw!8m2!3d55.6570083!4d37.5577278!9m1!1b1!16s%2Fg%2F11r925q2y!3m5!1s0x46b54bd53dd429dd:0xf026259b7dbd3925!8m2!3d55.6570083!4d37.5577278!16s%2Fg%2F11r925q2y:

image

Playground | Inspect

However, a place result is returned in Google Maps when opening the google_maps_url link from the response above, which contains the same data paraemter:

image

Google Maps

Intercom

aciddjus commented 1 month ago

Thanks, @martin-serpapi

That is not a valid way to pass a data parameter for a place. Per our documentationion, data parameter should be contracted in the following sequence:

!4m5!3m4!1s + data_id + !8m2!3d + latitude + !4d + longitude

That translates to:

!4m5!3m4!1s0x46b54bd53dd429dd:0xf026259b7dbd3925!8m2!3d55.6570083!4d37.5577278

Playground | Inspect

marm123 commented 1 month ago

Thanks for looking into it, @aciddjus!

I think the main issue here is that the data parameter Martin shared in the example, although not created in the way described in our documentation, works directly in Google Maps but doesn't work with our API.

Do you think we can potentially support a different data format than the one described in the documentation?

aciddjus commented 1 month ago

Thanks, @marm123

I think I understand the problem. Coping the complete data parameter of a place should already work:

Google Maps link

Playground with full data parameter


The problem starts when you are on Google Maps, and after visiting one place, you click on another. In my example, I clicked this town

If we extract the data parameter from this search:

!3m1!4b1!4m14!1m7!3m6!1s0x46b54bd53dd429dd:0xf026259b7dbd3925!2z0KDQvtGB0LPQtdC-0LvQvtCz0LjRjw!8m2!3d55.6570083!4d37.5577278!16s%2Fg%2F11r925q2y!3m5!1s0x46b55a5a72e3e52f:0xc87750bc121a9f52!8m2!3d55.6995987!4d37.1481532!16s%2Fg%2F12z655f6t

You can see that it contains two sets of data required parameters

First: data_id: 0x46b54bd53dd429dd:0xf026259b7dbd3925 latitude: 55.6570083 longitude: 37.5577278

Playground

Second: data_id: 0x46b55a5a72e3e52f:0xc87750bc121a9f52 latitude: 55.6995987 longitude: 37.1481532

Playground


So, the first data set is residue from your previous search, and the last data set is from your current search (I wasn't able to reproduce the user's case, where both sets are the same). This doesn't happen every time, and I don't quite understand the reason (it could be a bug in async URL construction on the Google Maps side, or it serves some real purpose).

I'm not sure why the redirect is not working properly on our side in these cases. But as a workaround, I would suggest opening a new browser tab or window, searching for a place, getting a "clean" URL, or following the steps provided in our documentation.