2017-07-01 52 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关于表单,并回答任何问题。

希望这会有所帮助!

相关问题