เอกสาร MapScale
•••
ผลิตภัณฑ์
ผลิตภัณฑ์

Search & Geocoding

ค้นหาสถานที่ขณะพิมพ์ แปลงที่อยู่เป็นพิกัด และแปลงพิกัดกลับเป็นที่อยู่ไทย

สิ่งที่คุณจะทำได้

ใช้ Autocomplete, Place Detail, Geocode และ Reverse Geocode เป็น flow เดียวกัน

เลือก endpoint

Autocomplete ใช้แสดงคำแนะนำระหว่างพิมพ์ Place Detail ใช้ resolve คำแนะนำที่เลือก Geocode ใช้กับที่อยู่แบบเต็มหรือค้นหาจาก server ส่วน Reverse Geocode ใช้ตั้งชื่อพิกัดที่คลิกหรือจาก GPS

Geocode สถานที่

ผลลัพธ์เป็น GeoJSON โดย geometry.coordinates เรียงเป็น [longitude, latitude] เสมอ ใช้ bbox หรือ proximity เพื่อให้ผลลัพธ์ใกล้ตัวมากขึ้น

LIVE API PLAYGROUND

เข้าสู่ระบบหรือสร้างบัญชี

ดำเนินการต่อเพื่อเรียก request จริงจากหน้า docs

แก้ไข input ส่ง request จริง และตรวจสอบ response จริง

input ที่แก้ไขได้

Request preview
curl \
  -H "X-MapScale-Key: $MAPSCALE_API_KEY" \
  "https://api.mapscale.io/v1/geocode?q=Siam+Paragon&lang=th&limit=5"
Response จริง
Response เริ่มต้น
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "place_bangkok_123",
      "text": "Siam Paragon",
      "place_name": "Siam Paragon, Pathum Wan, Bangkok",
      "geometry": {
        "type": "Point",
        "coordinates": [
          100.5348,
          13.7466
        ]
      },
      "properties": {
        "latitude": 13.7466,
        "longitude": 100.5348,
        "formattedAddress": "Siam Paragon, Pathum Wan, Bangkok 10330, Thailand",
        "street": "Rama I Road",
        "neighborhood": "Siam",
        "subdistrict": "Pathum Wan",
        "district": "Pathum Wan",
        "province": "Bangkok",
        "postalCode": "10330",
        "country": "Thailand"
      }
    }
  ]
}

ตัวอย่าง geocode ที่สอง

endpoint เดียวกัน คำค้นต่างกัน — รูปแบบ response ไม่เปลี่ยน

LIVE API PLAYGROUND

เข้าสู่ระบบหรือสร้างบัญชี

ดำเนินการต่อเพื่อเรียก request จริงจากหน้า docs

แก้ไข input ส่ง request จริง และตรวจสอบ response จริง

input ที่แก้ไขได้

Request preview
curl \
  -H "X-MapScale-Key: $MAPSCALE_API_KEY" \
  "https://api.mapscale.io/v1/geocode?q=Central+World&lang=th&limit=5"
Response จริง
Response เริ่มต้น
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "place_bangkok_123",
      "text": "Siam Paragon",
      "place_name": "Siam Paragon, Pathum Wan, Bangkok",
      "geometry": {
        "type": "Point",
        "coordinates": [
          100.5348,
          13.7466
        ]
      },
      "properties": {
        "latitude": 13.7466,
        "longitude": 100.5348,
        "formattedAddress": "Siam Paragon, Pathum Wan, Bangkok 10330, Thailand",
        "street": "Rama I Road",
        "neighborhood": "Siam",
        "subdistrict": "Pathum Wan",
        "district": "Pathum Wan",
        "province": "Bangkok",
        "postalCode": "10330",
        "country": "Thailand"
      }
    }
  ]
}

สร้างช่องค้นหาที่เชื่อถือได้

หน่วงการพิมพ์ (debounce) ใช้ session_token เดียวตั้งแต่คำแนะนำแรกจนถึง Place Detail และรอให้ผู้ใช้เลือกผลลัพธ์ก่อนขยับแผนที่

อ่านต่อขั้นตอนถัดไป

On this page