我一直在關注一個偉大的教程,允許用戶輸入郵編,然後ListView顯示與郵編匹配的全球各地的地點。一旦單擊了填充的ListView中的地址,它的位置就會通過mapView上的標記顯示出來。從geonames執行Google API搜索
我已經完成了本教程,並且一直在處理HTTP Web服務。目前代碼正在使用'geonames'數據庫的在線服務來查詢提供的郵政編碼我現在想要將Google API應用到我的代碼中以搜索超市。
的GEONAMES使用來自所提供的郵政編碼以下列格式的JSON響應:
{"postalCodes":[{"adminName2":"El Paso","adminCode2":"041","adminCode1":"CO","postalCode":"80907","countryCode":"US","lng":-104.817034,"placeName":"Colorado Springs","lat":38.876001,"adminName1":"Colorado"}]}
上述字符串是從「80907」一個郵政編碼。
這是GEONAMES的字符串URL:
private static final String GEONAME_RESTURL
= "http://api.geonames.org/postalCodeSearchJSON?maxRows=8&username=demo&postalcode=";
我已閱讀谷歌API文檔,發現以下「附近搜索request'search字符串:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&types=food&name=harbour&sensor=false&key=AddYourOwnKeyHere
這裏是代碼返回的郵政編碼匹配:
DataWrapper wrap = new DataWrapper();
wrap = wrap.fromJson(responseString);
return wrap.postalCodes;
我怎樣才能找到這個如上所示返回的JSON搜索字符串與超市的Google搜索字符串的geoname結果?
我意識到我可以修復搜索半徑到指定的數字,但我想接收匹配我的搜索字符串列出超市。
希望我已經清楚這個問題!