2015-03-19 55 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