เริ่มต้นใช้งาน Geocoding API v4

นักพัฒนาซอฟต์แวร์ในเขตเศรษฐกิจยุโรป (EEA)

Geocoding API v4 เป็นบริการที่ให้การเข้ารหัสพิกัดภูมิศาสตร์ การเข้ารหัสพิกัดภูมิศาสตร์แบบย้อนกลับ ของที่อยู่และรหัสสถานที่ รวมถึงข้อมูลปลายทาง

การเข้ารหัสพิกัดภูมิศาสตร์คือกระบวนการแปลงที่อยู่ (เช่น ที่อยู่) เป็นพิกัดทางภูมิศาสตร์ (เช่น ละติจูดและลองจิจูด) ซึ่งคุณสามารถใช้เพื่อวางเครื่องหมาย บนแผนที่หรือจัดตำแหน่งแผนที่ได้

การเข้ารหัสพิกัดภูมิศาสตร์แบบย้อนกลับคือกระบวนการแปลงพิกัดทางภูมิศาสตร์ เป็นที่อยู่ที่มนุษย์อ่านได้

นอกจากนี้ คุณยังใช้ Geocoding API เพื่อค้นหาที่อยู่สำหรับรหัสสถานที่ที่ระบุได้ด้วย

ตัวอย่างคำขอและการตอบกลับ

คุณเข้าถึง Geocoding API ผ่านอินเทอร์เฟซ HTTP ต่อไปนี้คือตัวอย่างคำขอการเข้ารหัสพิกัดภูมิศาสตร์และการเข้ารหัสพิกัดภูมิศาสตร์แบบย้อนกลับ

คำขอและการตอบกลับการแปลงพิกัดภูมิศาสตร์ (การค้นหาละติจูด/ลองจิจูด)

ตัวอย่างต่อไปนี้จะขอละติจูดและลองจิจูดของ "1600 Amphitheatre Parkway, Mountain View, CA" และระบุว่าเอาต์พุตต้องอยู่ในรูปแบบ JSON

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

คุณทดสอบได้โดยป้อน URL ลงในเว็บเบราว์เซอร์ (อย่าลืมแทนที่ YOUR_API_KEY ด้วยคีย์ API จริงของคุณ) การตอบกลับจะมีละติจูดและลองจิจูดของที่อยู่

ดูข้อมูลเพิ่มเติมเกี่ยวกับ การสร้าง URL ของคำขอ Geocoding พารามิเตอร์ที่ใช้ได้ และ การทำความเข้าใจการตอบกลับได้ในคู่มือนักพัฒนาแอป

ด้านล่างนี้คือตัวอย่างการตอบกลับการแปลงพิกัดทางภูมิศาสตร์ใน JSON

{
  "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"
      ]
    }
  ]
}

คำขอและการตอบกลับการเข้ารหัสพิกัดภูมิศาสตร์แบบย้อนกลับ (การค้นหาที่อยู่)

ตัวอย่างต่อไปนี้จะขอที่อยู่ที่สอดคล้องกับละติจูด/ลองจิจูดที่ระบุ ในบรูคลิน นิวยอร์ก สหรัฐอเมริกา ซึ่งระบุว่าเอาต์พุตต้องอยู่ในรูปแบบ JSON

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

คุณทดสอบได้โดยป้อน URL ลงในเว็บเบราว์เซอร์ (อย่าลืมแทนที่ "YOUR_API_KEY" ด้วยคีย์ API จริงของคุณ) การตอบกลับจะมีที่อยู่ที่มนุษย์อ่านได้สำหรับตำแหน่งละติจูดและลองจิจูด

ดูข้อมูลเพิ่มเติมเกี่ยวกับ การสร้าง URL คำขอการแปลงพิกัดทางภูมิศาสตร์ย้อนกลับ พารามิเตอร์ที่ใช้ได้ และ การทำความเข้าใจการตอบกลับได้ในคู่มือนักพัฒนาแอป

ด้านล่างนี้คือตัวอย่างการตอบกลับการแปลงพิกัดทางภูมิศาสตร์ย้อนกลับใน JSON

{
  "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[] ...
}

การตรวจสอบสิทธิ์ โควต้า ราคา และนโยบาย

การตรวจสอบสิทธิ์

หากต้องการใช้ Geocoding API คุณต้องเปิดใช้ API และรับข้อมูลเข้าสู่ระบบการตรวจสอบสิทธิ์ที่เหมาะสมก่อน ดูข้อมูลเพิ่มเติมได้ที่ เริ่มต้นใช้งาน Google Maps Platform

โควต้าและการกำหนดราคา

ดูรายละเอียดเกี่ยวกับโควต้าและราคาที่ตั้งไว้สำหรับ Geocoding API ได้ในหน้าการใช้งานและการเรียกเก็บเงิน

นโยบาย

การใช้ Geocoding API ต้องเป็นไปตาม นโยบาย API