Search code examples
google-mapsgoogle-maps-api-3geocodinggeospatialgeo

How does Airbnb implement geo searching?


I'm exploring how does Airbnb stuff work and interested in geo searching. I don't understand how does Airbnb finds their ads by New Zealand for example?

If to look at query string parameters:

page:1
location:New Zealand
ss_id:3sdsi3ff

Only location string New Zealand goes to the server but not coordinates like lng, lat.

But in the response we get back the following:

center_lat: -40.900557
center_lng: 174.885971,
geo: {accuracy: 1, district: null, city: null, state: null, country: "New Zealand", country_code: "NZ",…}
accuracy: 1
city: null
colloquial_area: null
country: "New Zealand"
country_code: "NZ"
district: null
market: "Other (International)"
natural_feature: null
result_type: "country"
state: null
state_short: null
success?: true

we see that we get center_lat: -40.900557 center_lng: 174.885971 coordinates, country: "New Zealand", country_code: "NZ"

So how does Airbnb could detect this data based on "New Zealand" string passed from client in GET request?


Solution

  • They either have a server that stored every single city in the world (name as key) and the position.... (Well... One can get all those information from Wikipedia)

    Or they must had used some services like the google map geocoding services:

    https://developers.google.com/maps/documentation/javascript/geocoding

    Open street map provide solution API like the google geocoding too.