Relative Content

Tag Archive for google-mapsgoogle-maps-api-3

MapsJsInternalService/GetViewportInfo returns 400 bad request

Recently, my embedded google map in my website is suddenly not working any more. While debugging using dev tool, I’ve spotted a failed request: https://maps.googleapis.com/$rpc/google.internal.maps.mapsjs.v1.MapsJsInternalService/GetViewportInfo returns 400 – bad request with response:

How to get the street address by searching ‘Postcode’ in the Google place api

Extracting Postal Code: The function starts by extracting the postal code from the input field.
Getting Place Details: It then retrieves details about the selected place using the Autocomplete service, just like before.
Creating Bounds from Viewport: Once the place details are obtained, it constructs a google.maps.LatLngBounds object using the viewport of the selected place. The viewport represents the area that encompasses the place, providing a bounding box.
Performing Nearby Search with Bounds: With the bounds defined, it sets up a nearby search request to find places within both the specified radius and the bounds. This biases the search results to only include places within the viewport of the selected place.
Displaying Results: Finally, it displays the nearby search results (street addresses) in a list format, allowing the user to select a specific address.