Skip to content
Advertisement

How can I get a random streetview location?

I am trying to write a JavaScript web application that allows me to get a random location that has Google Street-view information.

The first step I took was to create a random latitude and longitude location, however as the Earth is mostly ocean, I ended up there more often than not. I then tried to use the closest location to those randomly selected points, however that made me end up on the shore, or in random underwater locations most of the time.

I also tried using an API to get lists of random on-land location, however that also included locations slightly off-shore, and often did not land on a street-view area (or near to one). It was close, but didn’t give me the best result.

The goal is to do this as efficiently as possible, while maintaining a relatively low amount of API calls.

As far as I could find, google does not publish a list of all of the locations with street-view information, which limits my possibilities for randomly selecting a location from a list.

I’m trying to achieve the effect of GeoGuessr.

Advertisement

Answer

StreetViewService

In their docs google describes how to get a streetview location.

See also this answer on stack overflow describing an example implementation.

Reverse geocoding

If that doesn’t work for you; I think your approach of reverse-geocoding random LatLon wouldn’t be that bad.

In their docs google describes request parameters for their reverse geocoder.

Perhaps you could use street or route as the result_type to at least narrow it down by a lot.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement