HTTP Request-GoogleMaps/API/doc/GeocoderExamples/04-HTTPRequest-N☆E 学習帳

[ リロード ]   [ ソース ]  [ トップ | 一覧 | 単語検索 | 最新 | バックアップ | ヘルプ ]

Counter: 4446, today: 2, yesterday: 3

HTTP Request

http://www.google.com/apis/maps/docu­mentation/

Version 2 (2006.6新規)

To access the Maps API geocoder directly using server-side scripting, send a request to http://maps.google.com/maps/geo? with the following parameters in the URI:

  • q -- The address that you want to geocode.
  • key -- Your API key.
  • output -- The format in which the output should be generated. The options are xml, kml or json.

In this example, we request the geographic coordinates of Google's headquarters.

http://maps.google.com/maps/geo?q=16­00+Amphitheatre+Parkway,+Mountain+Vi­ew,+CA&output=xml&key=abcdefg

If you specify json as the output, the response is formatted as a JSON object, as shown in the example above. If you specify xml or kml, the response is returned in XML or KML. The XML and KML outputs are identical except for the MIME types.

For example, this is the response that the geocoder returns for "1600 amphitheatre mtn view ca".

<kml>
 <Response>
  <name>1600 amphitheatre mtn view ca</name>
  <Status>
   <code>200</code>
   <request>geocode</request>
  </Status>
  <Placemark>
   <address>
    1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA
   </address>
   <AddressDetails Accuracy="8"> (2006.7追加)
    <Country>
     <CountryNameCode>US</CountryNameCode>
      <AdministrativeArea>
      <AdministrativeAreaName>CA</AdministrativeAreaName>
      <SubAdministrativeArea>
       <SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
       <Locality>
        <LocalityName>Mountain View</LocalityName>
        <Thoroughfare>
         <ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName>
        </Thoroughfare>
        <PostalCode>
         <PostalCodeNumber>94043</PostalCodeNumber>
        </PostalCode>
       </Locality>
      </SubAdministrativeArea>
     </AdministrativeArea>
    </Country>
   </AddressDetails>
   <Point>
    <coordinates>-122.083739,37.423021,0</coordinates>
   </Point>
  </Placemark>
 </Response>
</kml>

以下2006.7追加

If you prefer a shorter response that is easier to parse and don't need special features like multiple results or pretty formatting, we also provide a csv output. A reply returned in the csv format consists of four numbers, separated by commas. The first number is the status code, the second is the accuracy, the third is the latitude, while the fourth one is the longitude. The following shows replies for three addresses, in increasing order of accuracy: "State St, Troy, NY", "2nd st & State St, Troy, NY" and "7 State St, Troy, NY"

200,6,42.730070,-73.690570
200,7,42.730210,-73.691800
200,8,42.730287,-73.692511

最初の数はGGeoStatusCode
2番目の数はAccuracy
3番目の数は緯度
4番目の数は経度