以 New York 為例, 輸入網址(若要傳回JSON 格式就把XML 換成JSON)
http://maps.google.com/maps/api/geocode/xml?address=New+York&sensor=false
傳回的格式如下
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
<result>
<type>locality</type>
<type>political</type>
<formatted_address>紐約, 紐約州, 美國</formatted_address>
<address_component>
<long_name>紐約</long_name>
<short_name>紐約</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>紐約</long_name>
<short_name>紐約</short_name>
<type>administrative_area_level_2</type>
<type>political</type>
</address_component>
<address_component>
<long_name>紐約</long_name>
<short_name>NY</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>美國</long_name>
<short_name>US</short_name>
<type>country</type>
<type>political</type>
</address_component>
<geometry>
<location>
<lat>40.7143528</lat>
<lng>-74.0059731</lng>
</location>
<location_type>APPROXIMATE</location_type>
<viewport>
<southwest>
<lat>40.5788964</lat>
<lng>-74.2620919</lng>
</southwest>
<northeast>
<lat>40.8495342</lat>
<lng>-73.7498543</lng>
</northeast>
</viewport>
<bounds>
<southwest>
<lat>40.4773990</lat>
<lng>-74.2590900</lng>
</southwest>
<northeast>
<lat>40.9175770</lat>
<lng>-73.7002720</lng>
</northeast>
</bounds>
</geometry>
</result>
</GeocodeResponse>
資料參考
http://code.google.com/intl/zh-TW/apis/maps/documentation/geocoding/
沒有留言:
張貼留言