ป้อนข้อมูลที่อยู่โดยอัตโนมัติ

คุณสามารถใช้ Google Places API บนเว็บไซต์ของคุณเพื่อให้แน่ใจว่าที่อยู่จัดส่งของผู้ใช้มีอยู่จริงและผู้ให้บริการสามารถเข้าใจได้ Google Places API ช่วยให้นักพัฒนาสามารถเข้าถึงข้อมูลโดยละเอียดเกี่ยวกับสถานที่ต่างๆ ได้โดยใช้คำขอ HTTP ระบบเติมคำอัตโนมัติจะคาดเดารายชื่อสถานที่เมื่อผู้ใช้เริ่มพิมพ์ที่อยู่

Address autocomplete example

To do so, go to Website ‣ Configuration ‣ Settings and enable Address Autocomplete in the SEO section.

Enable address autocomplete

Insert your Google Places API key in the API Key field. If you don't have one, create yours on the Google Cloud Console and follow these steps.

Step 1: Enable the Google Places API

Create a New Project: To enable the Google Places API, you first need to create a project. To do so, click Select a project in the top left corner, New Project, and follow the prompts to set up your project.

Enable the Google Places API: Go to the Enabled APIs & Services and click + ENABLE APIS AND SERVICES. Search for "Places API" and select it. Click on the "Enable" button.

Note

ราคาของ Google ขึ้นอยู่กับจำนวนคำขอและความซับซ้อนของคำขอ

ขั้นตอนที่ 2: สร้างข้อมูลรับรอง API

ไปที่ APIs & Services --> Credentials

สร้างข้อมูลรับรอง: เพื่อสร้างข้อมูลรับรองของคุณ ไปที่ Credentials คลิก Create Credentials และเลือก API key

จำกัดคีย์ API (ไม่บังคับ)

เพื่อความปลอดภัย คุณสามารถจำกัดการใช้งานคีย์ API ของคุณได้ คุณสามารถไปที่ส่วน API restrictions เพื่อระบุว่า API ใดที่คีย์ของคุณสามารถเข้าถึงได้ สำหรับ Google Places API คุณสามารถจำกัดให้อนุญาตเฉพาะคำขอจากเว็บไซต์หรือแอปเฉพาะเจาะจง

Important

  • บันทึกคีย์ API ของคุณ: คัดลอกคีย์ API ของคุณและเก็บไว้อย่างปลอดภัย

  • อย่าแชร์คีย์นี้ต่อสาธารณะหรือเปิดเผยในโค้ดฝั่งไคลเอนต์