Geocoding API 的 SearchDestinations 方法現在包含目的地的詳細停車資訊。這些資料可協助使用者規劃行程,例如:
- 瞭解抵達時可使用的停車設施。
- 評估要預留多少時間找停車位。
要求停車資訊
如要接收停車資訊,請務必在要求欄位遮罩中加入 destinations.parkingOptions。使用 X-Goog-FieldMask 標頭指定要在回應中傳回的欄位。
cURL 要求範例
curl -X POST -d '{
"place": "places/ChIJcWnnWiz0wokRCB6aVdnDQEk"
}' \
-H 'Content-Type: application/json' \
-H "X-Goog-Api-Key: API_KEY" \
-H "X-Goog-FieldMask: destinations.primary.place,destinations.parkingOptions" \
https://geocode.googleapis.com/v4alpha/geocode/destinations
瞭解回應
如果提出要求,回應中的 Destination 物件會包含 parkingOptions 欄位。
parkingOptions
這個物件包含目的地停車情況的詳細資料。
停車位類型:布林值旗標,指出是否有特定停車位類型:
onsiteParking:如果目的地有附設停車場,則為 True。freeParkingLot:如果提供免費停車場,則為 True。paidParkingLot:如果提供付費停車場,則為 True。freeStreetParking:如果提供免費路邊車位,則為 True。paidStreetParking:如果提供付費路邊車位,則為 True。valetParking:如果提供代客泊車服務,則為 True。freeGarageParking:如果提供免費室內停車位,則為 True。paidGarageParking:如果提供付費室內停車場,則為 True。
Availability:列舉,表示尋找停車位的難易度:
AVAILABILITY_UNSPECIFIED:無法提供停車位資訊。PLENTY:通常很容易找到停車位。SOMEWHAT_DIFFICULT:停車位可能不好找。DIFFICULT:通常很難找到停車位。
Parking Facilities (
parkingFacilities):ParkingFacility物件清單,代表與目的地相關聯的個別停車選項 (例如特定室內停車場或停車場):place:代表特定停車設施的PlaceView(包括其place、placeId、displayName、location、formattedAddress和displayPolygon)。onsite:如果停車場位於主要目的地,則為 True。popular:如果停車場是前往主要目的地的旅客熱門選擇,則為 True。straightLineDistanceMeters:從主要目的地到這個停車設施的直線距離 (以公尺為單位)。
回應程式碼片段範例
{
"destinations": [
{
"primary": {
"place": "places/ChIJcWnnWiz0wokRCB6aVdnDQEk",
"displayName": {
"text": "Yankee Stadium",
"languageCode": "en"
}
// ... other primary place fields
},
"parkingOptions": {
"paidParkingLot": true,
"freeStreetParking": true,
"paidStreetParking": true,
"paidGarageParking": true,
"onsiteParking": true,
"parkingFacilities": [
{
"place": {
"place": "places/ChIJ8TdM8y70wokRToHbbtCEthQ",
"placeId": "ChIJ8TdM8y70wokRToHbbtCEthQ",
"displayName": {
"text": "164th St Parking Garage",
"languageCode": "en"
},
"primaryType": "parking_garage",
"formattedAddress": "164th St Parking Garage, 65 W 164th St, Bronx, NY 10452, USA",
"structureType": "POINT",
"location": {
"latitude": 40.830543999999996,
"longitude": -73.924656
}
// ... other place fields
},
"onsite": true,
"popular": false
},
{
"place": {
"place": "places/ChIJ-zvoYG71wokRElYeJWoI9GY",
"placeId": "ChIJ-zvoYG71wokRElYeJWoI9GY",
"displayName": {
"text": "River Ave. Parking Garage",
"languageCode": "en"
},
"primaryType": "parking_garage",
"formattedAddress": "River Ave. Parking Garage, 999-943 River Ave, Bronx, NY 10452, USA",
"structureType": "POINT",
"location": {
"latitude": 40.8298561,
"longitude": -73.9245919
}
// ... other place fields
},
"onsite": false,
"popular": false,
"straightLineDistanceMeters": 12.754842758178711
}
// ... other parking facilities
]
}
// ... other destination fields
}
]
}
意見回饋
這是 Geocoding API 的實驗功能。歡迎透過 geocoding-feedback-channel@google.com 提供意見。