2015-03-19 88 views
0

我在探索Airbnb的工作原理,並對地理搜索感興趣。我不明白Airbnb如何通過New Zealand找到他們的廣告?Airbnb如何實現地理搜索?

如果看一下查詢字符串參數:

page:1 
location:New Zealand 
ss_id:3sdsi3ff 

只有位置字符串New Zealand進入到服務器,但不是像座標LNG,LAT。

但在響應我們得到以下:

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 

我們看到,我們得到center_lat: -40.900557 center_lng: 174.885971座標,國家:"New Zealand",COUNTRY_CODE:"NZ"

那麼,如何製作的Airbnb可以檢測基於該數據在GET請求中從客戶端傳遞的「新西蘭」字符串?

回答

2

他們要麼是存儲每一個城市在世界上的服務器(名作爲關鍵字)和位置......(嗯...一個可以從維基百科的所有信息)

,或者必須曾使用的一些服務,如谷歌地圖服務,地理編碼:

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

開放街道地圖提供的解決方案API,如谷歌的地理編碼了。

+0

那麼有可能在服務器端使用地理編碼?我使用nodejs服務器 – Erik 2015-03-19 10:20:14

+0

我認爲你可以使用相同的API,因爲注意js只是JavaScript ... – kaho 2015-03-19 13:22:47

+0

你的意思是Google Maps API? – Erik 2015-03-19 13:24:21