Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Cara mencari di dekatnya di suatu negara
SearchNearby API memungkinkan Anda untuk mencari tempat terdekat di negara tertentu. Untuk menggunakan API, Anda perlu menyediakan QueryPosition, yang dapat berupa:
-
Posisi perangkat
-
Posisi berbasis IP
-
Pusat viewport peta
Atau, pengguna dapat memberikan nama kota atau tempat, dan aplikasi dapat membiaskan hasil berdasarkan geokoordinat lokasi tersebut.
Kasus penggunaan potensial
-
Jelajahi bisnis dalam suatu negara
-
Temukan pelanggan B2B terdekat di suatu negara
-
Jelajahi tempat-tempat wisata di suatu negara
Contoh
Contoh berikut menunjukkan cara mencari lapangan golf di Kanada dekat koordinat yang ditentukan.
- Sample request
-
Permintaan ini mencari lapangan golf di Kanada dekat lokasi yang ditentukan.
{
"QueryPosition": [
-122.741803,
49.002478
],
"Filter" : {
"IncludeCategories": ["golf_course"],
"IncludeCountries": ["CAN"]
}
}
- Sample response
-
{
"ResultItems": [
{
"PlaceId": "<Redacted>",
"PlaceType": "PointOfInterest",
"Title": "Peace Portal Golf Course",
"Address": {
"Label": "Peace Portal Golf Course, 16900 * Ave, Surrey, BC V*Z *P*, Canada",
"Country": {
"Code2": "CA",
"Code3": "CAN",
"Name": "Canada"
},
"Region": {
"Code": "BC",
"Name": "British Columbia"
},
"SubRegion": {
"Name": "Metro Vancouver"
},
"Locality": "Surrey",
"District": "South Surrey",
"PostalCode": "V*Z *P*",
"Street": "* Ave",
"StreetComponents": [
{
"BaseName": "4",
"Type": "Ave",
"TypePlacement": "AfterBaseName",
"TypeSeparator": " ",
"Language": "en"
}
],
"AddressNumber": "16900"
},
"Position": [
-122.75086,
49.00921
],
"Distance": 998,
"Categories": [
{
"Id": "golf_course",
"Name": "Golf Course",
"LocalizedName": "Golf Course",
"Primary": true
}
],
"Contacts": {
"Phones": [
{
"Value": "+16045384818" }
],
"Websites": [
{
"Value": "http://www.peaceportalgolf.com"
}
]
},
"AccessPoints": [
{
"Position": [
-122.75087,
49.00935
]
}
]
}
]
}
- cURL
-
curl --request POST \
--url 'https://places.geo.eu-central-1.amazonaws.com/v2/search-nearby?key=Your_Key' \
--header 'Content-Type: application/json' \
--data '{
"QueryPosition": [
-122.741803,
49.002478
],
"Filter" : {
"IncludeCategories": ["golf_course"],
"IncludeCountries": ["CAN"]
}
}'
- AWS CLI
-
aws geo-places search-nearby --key ${YourKey} \
--query-position -122.741803 49.002478 \
--filter '{"IncludeCategories": ["golf_course"], "IncludeCountries": ["CAN"]}'