העברה לחיפוש בקרבת מקום (חדש)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מפתחים באזור הכלכלי האירופי (EEA)
מבוא
Places API תומך ב-Nearby Search (גרסה קודמת).
אם אתם מכירים את הגרסה הקודמת של 'חיפוש בקרבת מקום', ב
גרסה החדשה של 'חיפוש בקרבת מקום' בוצעו השינויים הבאים:
- הכלי החדש לחיפוש בקרבת מקום משתמש בבקשות HTTP POST.
מעבירים פרמטרים בגוף הבקשה או בכותרות כחלק מבקשת HTTP POST. לעומת זאת, בחיפוש בסביבה הקרובה (גרסה קודמת),
מעבירים פרמטרים של כתובת URL באמצעות בקשת HTTP GET.
- חובה לבצע אנונימיזציה של השדה. צריך לציין אילו שדות רוצים להחזיר בתגובה. אין רשימת ברירת מחדל של שדות שמוחזרים. אם לא מציינים את הרשימה הזו, השיטות מחזירות שגיאה. מידע נוסף מופיע במאמר בנושא FieldMask.
- הכלי 'חיפוש בקרבת מקום' (חדש) תומך במפתחות API ובאסימוני OAuth כמנגנון אימות.
- רק JSON נתמך כפורמט תגובה בחיפוש בקרבת מקום (חדש).
- כל הבקשות שכוללות שאילתת טקסט צריכות להשתמש עכשיו בחיפוש טקסט (חדש) כי חיפוש בסביבה (חדש) לא תומך בהזנת טקסט.
- פורמט התגובה ב-JSON של Nearby Search (חדש)
השתנה מהפורמט של ממשקי ה-API מדור קודם. פרטים נוספים זמינים במאמר בנושא העברת התגובה של Places API.
בטבלה הבאה מפורטים פרמטרים בחיפוש בקרבת מקום (גרסה קודמת) ששמם שונה או שהם שונו בחיפוש בקרבת מקום (גרסה חדשה), או פרמטרים שכבר לא נתמכים.
הפרמטר הנוכחי |
פרמטר חדש |
הערות |
keyword |
|
לא נתמכת. במקום זאת, אתם צריכים להשתמש בחיפוש טקסט (חדש). |
language |
languageCode |
|
location |
locationRestriction |
חובה. |
maxprice/minprice |
|
לא נתמכת. |
|
maxResultCount |
פרמטר חדש. |
opennow |
|
לא נתמכת. |
pagetoken |
|
לא נתמכת. |
radius |
|
אפשר להשתמש ב-locationRestriction עכשיו. |
rankby |
rankPreference |
|
|
regionCode |
פרמטר חדש. |
type |
includedTypes
excludedTypes
includedPrimaryTypes
excludedPrimaryTypes
|
הפרמטרים החדשים מקבלים גם ערכים מרובים של סוגים. ב-API מדור קודם
אפשר להזין רק ערך אחד. |
דוגמה לבקשה
בדוגמה הבאה מוצגת בקשת GET שמשתמשת בחיפוש בקרבת מקום (גרסה קודמת). בדוגמה הזו, אתם מבקשים תגובת JSON שמכילה מידע על מקומות מסוג restaurant
ומעבירים את כל הפרמטרים כפרמטרים של כתובת URL:
curl -L -X GET \
'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.7937%2C-122.3965&radius=500&type=restaurant&key=API_KEY'
בחיפוש בסביבה הקרובה (חדש), שולחים בקשת POST ומעבירים את כל הפרמטרים בגוף בקשת ה-JSON או בכותרות כחלק מבקשת ה-POST.
בדוגמה הזו נעשה שימוש גם במסכת שדות, כך שהתשובה כוללת רק את השם המוצג ואת הכתובת המעוצבת של המקום:
curl -X POST -d '{
"includedTypes": ["restaurant"],
"locationRestriction": {
"circle": {
"center": {
"latitude": 37.7937,
"longitude": -122.3965},
"radius": 500.0
}
}
}' \
-H 'Content-Type: application/json' -H "X-Goog-Api-Key: API_KEY" \
-H "X-Goog-FieldMask: places.displayName,places.formattedAddress" \
https://places.googleapis.com/v1/places:searchNearby
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-29 (שעון UTC).
[null,null,["עדכון אחרון: 2025-08-29 (שעון UTC)."],[],[],null,["# Migrate to Nearby Search (New)\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nIntroduction\n------------\n\nPlaces API supports\n[Nearby Search (Legacy)](/maps/documentation/places/web-service/search-nearby).\nIf you are familiar with Nearby Search (Legacy), the [Nearby Search (New)](/maps/documentation/places/web-service/nearby-search) makes the following\nchanges:\n\n- Nearby Search (New) uses HTTP POST requests. Pass parameters in the request body or in headers as part of an HTTP POST request. In contrast, with Nearby Search (Legacy), you pass URL parameters using an HTTP GET request.\n- Field masking is required. You must specify which fields you want returned in the response. There is no default list of returned fields. If you omit this list, the methods return an error. For more information, see [FieldMask](/maps/documentation/places/web-service/nearby-search#fieldmask).\n- Nearby Search (New) supports both [API keys](/maps/documentation/places/web-service/get-api-key) and [OAuth](/maps/documentation/places/web-service/oauth-token) tokens as the authentication mechanism.\n- Only JSON is supported as a response format in Nearby Search (New).\n- All requests that include a text query should now use [Text Search (New)](/maps/documentation/places/web-service/text-search) because Nearby Search (New) does not support text input.\n- The JSON response format for Nearby Search (New) has changed from the format of the legacy APIs. For more details, see [Migrate the Places API response](/maps/documentation/places/web-service/migrate-response).\n\nThe following table lists parameters in Nearby Search (Legacy) that have been\nrenamed or modified for Nearby Search (New), or parameters that are no\nlonger supported.\n\n| Current parameter | New parameter | Notes |\n|---------------------|-------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|\n| `keyword` | | Not supported. Use [Text Search (New)](/maps/documentation/places/web-service/text-search) instead. |\n| `language` | `languageCode` | |\n| `location` | `locationRestriction` | Required. |\n| `maxprice/minprice` | | Not supported. |\n| | `maxResultCount` | New parameter. |\n| `opennow` | | Not supported. |\n| `pagetoken` | | Not supported. |\n| `radius` | | Use `locationRestriction` now. |\n| `rankby` | `rankPreference` | |\n| | `regionCode` | New parameter. |\n| `type` | `includedTypes` `excludedTypes` `includedPrimaryTypes` `excludedPrimaryTypes` | The new parameters also accept multiple type values. The legacy API only accepts a single value. |\n\nExample request\n---------------\n\nThe following example GET request uses the Nearby Search (Legacy). In this\nexample, you request a JSON response containing information about places of type\n`restaurant` and pass all parameters as URL parameters: \n\n```curl\ncurl -L -X GET \\\n'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=37.7937%2C-122.3965&radius=500&type=restaurant&key=API_KEY'\n```\n\nWith Nearby Search (New), you make a POST request and pass all\nparameters in the JSON request body or in headers as part of the POST request.\nThis example also uses a field mask so the response only includes the display\nname and formatted address of the place: \n\n```curl\ncurl -X POST -d '{\n \"includedTypes\": [\"restaurant\"],\n \"locationRestriction\": {\n \"circle\": {\n \"center\": {\n \"latitude\": 37.7937,\n \"longitude\": -122.3965},\n \"radius\": 500.0\n }\n }\n}' \\\n-H 'Content-Type: application/json' -H \"X-Goog-Api-Key: API_KEY\" \\\n-H \"X-Goog-FieldMask: places.displayName,places.formattedAddress\" \\\nhttps://places.googleapis.com/v1/places:searchNearby\n```"]]