2017-07-01 49 views
-2

我在vb.net中有一個小應用程序,其中包含一個文本框,一個搜索按鈕和一個標籤。通過vb.net的名稱和郵政編碼搜索城市的API

我在互聯網上搜索過,但我沒有找到我想找的東西,所以我希望你能幫我一把。

我的應用程序有一個簡單的作用,通過名稱或郵政編碼檢測城市(文本框組件的行爲應該像城市,村莊等的搜索框)。然後通過單擊按鈕標籤採取文本框的文本。

我知道我可以用這小小的一行代碼來做最後一部分:label.text = textbox.text。

但我不知道在哪裏可以找到一個好的地圖API和文本框的行爲像一個搜索框的好功能。

我搜索到了stackoverflow的主題,但沒有任何幫助。也許別人也會需要這個在furure ...

謝謝你提前。

+1

嗨,adrian,歡迎來到SO。你的問題太廣泛了。請查看以下內容以改進您的問題:https://stackoverflow.com/help/on-topic – petezurich

+1

它的關閉主題是因爲它要求提供非現場資源 – Plutonix

回答

0

在過去,我已經使用了GeoCoding API

可以稱之爲是這樣的:

http://maps.googleapis.com/maps/api/geocode/json?address=94016&sensor=true

返回該JSON數據:

{ 
    "results" : [ 
     { 
     "address_components" : [ 
      { 
       "long_name" : "94016", 
       "short_name" : "94016", 
       "types" : [ "postal_code" ] 
      }, 
      { 
       "long_name" : "Outer Mission", 
       "short_name" : "Outer Mission", 
       "types" : [ "neighborhood", "political" ] 
      }, 
      { 
       "long_name" : "Daly City", 
       "short_name" : "Daly City", 
       "types" : [ "locality", "political" ] 
      }, 
      { 
       "long_name" : "San Francisco County", 
       "short_name" : "San Francisco County", 
       "types" : [ "administrative_area_level_2", "political" ] 
      }, 
      { 
       "long_name" : "California", 
       "short_name" : "CA", 
       "types" : [ "administrative_area_level_1", "political" ] 
      }, 
      { 
       "long_name" : "United States", 
       "short_name" : "US", 
       "types" : [ "country", "political" ] 
      } 
     ], 
     "formatted_address" : "Daly City, CA 94016, USA", 
     "geometry" : { 
      "location" : { 
       "lat" : 37.71, 
       "lng" : -122.45 
      }, 
      "location_type" : "APPROXIMATE", 
      "viewport" : { 
       "northeast" : { 
        "lat" : 37.7113489802915, 
        "lng" : -122.4486510197085 
       }, 
       "southwest" : { 
        "lat" : 37.7086510197085, 
        "lng" : -122.4513489802915 
       } 
      } 
     }, 
     "place_id" : "ChIJWSqQqDx8j4ARXJte4A-IYow", 
     "types" : [ "postal_code" ] 
     } 
    ], 
    "status" : "OK" 
} 

至於文本框像搜索框一樣工作,這是一個非常廣泛的主題!嘗試一些來自W3School的教程,如this one關於表單,並回答任何問題。

希望這會有所幫助!

相關問題