Geocoding API v4'ü kullanmaya başlama

Avrupa Ekonomik Alanı'ndaki (AEA) geliştiriciler

Geocoding API v4, iki temel özellik ailesi sunar: zengin yakın çevreye özel özellikler için hedef arama ve temel coğrafi kodlama (koordinat-adres dönüştürme). Hangi yöntemi kullanacağınızdan emin değil misiniz? Coğrafi kodlama yöntemi seçme bölümüne bakın.

Örnek istekler ve yanıtlar

Geocoding API'ye bir HTTP arayüzü üzerinden erişirsiniz. Aşağıda, Varış noktası arama, ileri coğrafi kodlama ve tersine coğrafi kodlama ile ilgili hızlı başlangıç örnekleri verilmiştir.

Varış noktası arama isteği ve yanıtı (yakın çevreye özel varış verileri)

Aşağıdaki örnekte, "1600 Amphitheatre Parkway, Mountain View, CA" için SearchDestinations adresine bir HTTP POST isteği gönderilmektedir. SearchDestinations, döndürülecek alanları belirten bir X-Goog-FieldMask başlığı gerektirir:

curl -X POST -d '{
  "addressQuery": {
    "addressQuery": "1600 Amphitheatre Parkway, Mountain View, CA"
  }
}' \
-H 'Content-Type: application/json' \
-H 'X-Goog-FieldMask: destinations.primary.displayName,destinations.primary.formattedAddress,destinations.primary.location,destinations.primary.displayPolygon,destinations.entrances,destinations.navigationPoints,destinations.landmarks' \
-H "X-Goog-Api-Key: YOUR_API_KEY" \
"https://geocode.googleapis.com/v4/geocode/destinations"

Aşağıda, bina ayak izi poligonunu, tercih edilen girişleri, rota çizilebilir navigasyon noktalarını ve yakındaki önemli yerleri gösteren örnek bir SearchDestinations yanıtı verilmiştir:

{
  "destinations": [
    {
      "primary": {
        "displayName": { "text": "Googleplex", "languageCode": "en" },
        "formattedAddress": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
        "location": { "latitude": 37.4220656, "longitude": -122.0840897 },
        "displayPolygon": {
          "type": "Polygon",
          "coordinates": [
            [
              [-122.084958, 37.422145],
              [-122.084112, 37.422610],
              [-122.083510, 37.421980],
              [-122.084958, 37.422145]
            ]
          ]
        }
      },
      "entrances": [
        {
          "location": { "latitude": 37.422189, "longitude": -122.084215 },
          "tags": ["PREFERRED"]
        }
      ],
      "navigationPoints": [
        {
          "navigationPointToken": "Eg...",
          "displayName": { "text": "Amphitheatre Pkwy Dropoff", "languageCode": "en" },
          "location": { "latitude": 37.421912, "longitude": -122.084301 },
          "travelModes": ["DRIVE"],
          "usages": ["DROPOFF", "PICKUP"]
        }
      ],
      "landmarks": [
        {
          "place": { "displayName": { "text": "Charleston Park", "languageCode": "en" } },
          "relationalDescription": { "text": "Adjacent to Charleston Park", "languageCode": "en" },
          "straightLineDistanceMeters": 85.4
        }
      ]
    }
  ]
}

Coğrafi kodlama isteği ve yanıtı (enlem/boylam arama)

Aşağıdaki örnekte "1600 Amphitheatre Parkway, Mountain View, CA" adresinin enlem ve boylamı istenmekte ve çıkışın JSON biçiminde olması gerektiği belirtilmektedir.

curl -H "X-Goog-Api-Key: YOUR_API_KEY" \
"https://geocode.googleapis.com/v4/geocode/address/1600+Amphitheatre+Parkway,+Mountain+View,+CA"

URL'yi web tarayıcınıza girerek bunu test edebilirsiniz (YOUR_API_KEY kısmını gerçek API anahtarınızla değiştirdiğinizden emin olun). Yanıtta adresin enlem ve boylam bilgileri yer alır.

Coğrafi kodlama isteği URL'leri oluşturma, kullanılabilir parametreler ve yanıtı anlama hakkında daha fazla bilgi için geliştirici kılavuzunu inceleyin.

Aşağıda, JSON biçiminde örnek bir coğrafi kodlama yanıtı verilmiştir:

{
  "results": [
    {
      "place": "//places.googleapis.com/places/ChIJ2Z2idB66j4ARI43TG-9RoCQ",
      "placeId": "ChIJ2Z2idB66j4ARI43TG-9RoCQ",
      "location": {
        "latitude": 37.4438238,
        "longitude": -122.0869895
      },
      "granularity": "ROOFTOP",
      "viewport": {
        "low": {
          "latitude": 37.4424748197085,
          "longitude": -122.0883384802915
        },
        "high": {
          "latitude": 37.445172780291493,
          "longitude": -122.08564051970852
        }
      },
      "formattedAddress": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
      "postalAddress": {
        "regionCode": "US",
        "languageCode": "en",
        "postalCode": "94043-1351",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "1600 Amphitheatre Pkwy"
        ]
      },
      "addressComponents": [
        {
          "longText": "1600",
          "shortText": "1600",
          "types": [
            "street_number"
          ]
        },
        {
          "longText": "Amphitheatre Parkway",
          "shortText": "Amphitheatre Pkwy",
          "types": [
            "route"
          ],
          "languageCode": "en"
        },
        {
          "longText": "Mountain View",
          "shortText": "Mountain View",
          "types": [
            "locality",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "Santa Clara County",
          "shortText": "Santa Clara County",
          "types": [
            "administrative_area_level_2",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "California",
          "shortText": "CA",
          "types": [
            "administrative_area_level_1",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "United States",
          "shortText": "US",
          "types": [
            "country",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "94043",
          "shortText": "94043",
          "types": [
            "postal_code"
          ]
        },
        {
          "longText": "1351",
          "shortText": "1351",
          "types": [
            "postal_code_suffix"
          ]
        }
      ],
      "types": [
        "premise",
        "street_address"
      ]
    }
  ]
}

Tersine coğrafi kodlama isteği ve yanıtı (adres arama)

Aşağıdaki örnekte, Brooklyn, NY, ABD'de belirli bir enlem/boylama karşılık gelen adres istenmektedir. Çıkışın JSON biçiminde olması gerektiğini belirtir.

https://geocode.googleapis.com/v4/geocode/location/37.4225508,-122.0846338?key=YOUR_API_KEY

URL'yi web tarayıcınıza girerek bunu test edebilirsiniz ("YOUR_API_KEY" ifadesini gerçek API anahtarınızla değiştirdiğinizden emin olun). Yanıtta, enlem ve boylam konumu için kullanıcıların okuyabileceği bir adres yer alıyor.

Tersine coğrafi kodlama istek URL'leri oluşturma, kullanılabilir parametreler ve yanıtı anlama hakkında daha fazla bilgi için geliştirici kılavuzunu inceleyin.

Aşağıda, JSON biçiminde örnek bir tersine coğrafi kodlama yanıtı verilmiştir:

{
  "results": [
    {
      "place": "//places.googleapis.com/places/ChIJHRNUiQK6j4ARJ__Hrbt6qsE",
      "placeId": "ChIJHRNUiQK6j4ARJ__Hrbt6qsE",
      "location": {
        "latitude": 37.4225657,
        "longitude": -122.08465439999999
      },
      "granularity": "ROOFTOP",
      "viewport": {
        "low": {
          "latitude": 37.421214719708509,
          "longitude": -122.08603273029148
        },
        "high": {
          "latitude": 37.423912680291508,
          "longitude": -122.0833347697085
        }
      },
      "bounds": {
        "low": {
          "latitude": 37.4225178,
          "longitude": -122.08484599999998
        },
        "high": {
          "latitude": 37.422609600000008,
          "longitude": -122.0845215
        }
      },
      "formattedAddress": "Google Building 40, 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
      "postalAddress": {
        "regionCode": "US",
        "languageCode": "en",
        "postalCode": "94043",
        "administrativeArea": "CA",
        "locality": "Mountain View",
        "addressLines": [
          "Google Building 40",
          "1600 Amphitheatre Pkwy"
        ]
      },
      "addressComponents": [
        {
          "longText": "Google Building 40",
          "shortText": "Google Building 40",
          "types": [
            "premise"
          ],
          "languageCode": "en"
        },
        {
          "longText": "1600",
          "shortText": "1600",
          "types": [
            "street_number"
          ]
        },
        {
          "longText": "Amphitheatre Parkway",
          "shortText": "Amphitheatre Pkwy",
          "types": [
            "route"
          ],
          "languageCode": "en"
        },
        {
          "longText": "Mountain View",
          "shortText": "Mountain View",
          "types": [
            "locality",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "Santa Clara County",
          "shortText": "Santa Clara County",
          "types": [
            "administrative_area_level_2",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "California",
          "shortText": "CA",
          "types": [
            "administrative_area_level_1",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "United States",
          "shortText": "US",
          "types": [
            "country",
            "political"
          ],
          "languageCode": "en"
        },
        {
          "longText": "94043",
          "shortText": "94043",
          "types": [
            "postal_code"
          ]
        }
      ],
      "types": [
        "street_address",
        "subpremise"
      ]
    },
    ... Additional results truncated in this example[] ...
}

Kimlik doğrulama, kotalar, fiyatlandırma ve politikalar

Kimlik doğrulama

Geocoding API'yi kullanmak için önce API'yi etkinleştirmeniz ve uygun kimlik doğrulama bilgilerini edinmeniz gerekir. Daha fazla bilgi için Google Haritalar Platformu'nu kullanmaya başlama başlıklı makaleyi inceleyin.

Kotalar ve fiyatlandırma

Geocoding API için belirlenen kotalar ve fiyatlandırma hakkında ayrıntılı bilgi edinmek için Kullanım ve Faturalandırma sayfasını inceleyin.

Politikalar

Geocoding API'nin kullanımı API politikalarına uygun olmalıdır.