کشف محلی را با Nearby Search (جدید) API بهبود دهید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
در این سند، نحوه استفاده از Nearby Search (جدید) API برای ساخت یک ساده و مقرون به صرفه را بررسی خواهید کرد.
تجربه کشف محلی
یک تجربه اکتشافی محلی به کاربران مکانهای کلیدی مورد علاقه نزدیک مکانی را که هنگام جستجوی هتل یا ملک مشخص میکنید نشان میدهد. اغلب از یک نقشه تعاملی، با یک پانل اضافی شامل یک انتخابگر مکان و یک گالری عکس تشکیل شده است. محصولات و قابلیتهای مختلف پلتفرم Google Maps به شما ارائه میشود تا تجربه را با تعامل افزایش دهید.

موارد استفاده
حال بیایید بفهمیم چه عناصری از یکپارچه سازی اکتشاف محلی ارزش کاربر را هدایت می کند:
کشف - با نمایاندن مکانهای مرتبط از انواع مختلف، به کاربران یک نمای کلی از آنچه در اطراف یک مکان وجود دارد ارائه دهید.
تعامل - به کاربران امکان می دهد مکان را انتخاب کنند و داده ها را به صورت پویا تازه کنند
نسبت به آن مکان
تجسم - بررسی مکان ها، عکس ها را ارائه دهید
و زمان و مسافت پیاده روی را برای کاربران به سرعت درک می کنند که آیا با نیازهای آنها مطابقت دارد یا خیر.
معماری مرجع

کشف محلی
راه های زیادی برای ایجاد یک تجربه کشف محلی وجود دارد. ادغام زیر نمونه ای سفارشی از یک تجربه کاربری است که از API های شناخته شده پلتفرم نقشه های گوگل و همچنین برخی از ویژگی های جدید هیجان انگیز استفاده می کند. اگر می خواهید یک رویکرد قالبی برای کشف محلی داشته باشید، می توانید از Web Components استفاده کنید.
نمونه برنامه
نمونه راهنما
در جدول زیر میتوانید نمونه برنامهای را که به مراحل مختلف تقسیم شده است، همراه با توضیحی درباره پیادهسازی فنی با APIهای پلتفرم Google Maps مشاهده خواهید کرد.
1. جستجوی مکان با AutocompleteSearch مکان
- API جاوا اسکریپت Maps را بارگیری کنید.
- پرس و جو تکمیل خودکار یا انتخاب مکان را روی نقشه قرار می دهد .

2. نقاط محلی مورد علاقه را با استفاده از Nearby Search (جدید) API نمایان کنید
- رتبه بندی محبوبیت (نتایج مرتبط تر) یا رتبه بندی فاصله.
-
includedTypes
, excludedTypes
; اگر شما یک هتل هستید، می توانید نوع اقامت را حذف کنید و فقط انواع مناسب را شامل شود، به عنوان مثال: "رستوران، کافه، پارک، جاذبه_ تور". - اهرم
includedPrimaryTypes
، excludedPrimaryTypes
برای کنترل بیشتر بر نتایج. - `محدودیت مکان برای جلوگیری از تعداد ناکافی نتایج یا مکان های بسیار دور. در صورت صفر بودن نتایج، اندازه دایره / مستطیل را قبل از نمایش نتایج، بزرگ کنید.

نمونه پرس و جو هنگام رزرو هتل با فیلدهای داده درخواست شده:
- پایه (
displayName
، types
، openingHours
، formattedAddress
) - تماس (
websiteUri
, nationalPhoneNumber
, internationalPhoneNumber
) - برگزیده (
reviews
، priceLevel
، userRatingCount
)
{ "includedTypes": ["restaurant","cafe","park"], "excludedTypes":
["lodging","convenience_store"], "includedPrimaryTypes":
["restaurant","tourist_attraction","airport"], "excludedPrimaryTypes":
["lodging"], "maxResultCount": 20, "locationRestriction": { "circle": {
"center": { "latitude": 37.7937, "longitude": -122.3965 }, "radius": 500.0 } } }
نمونه پرس و جو هنگام جستجوی یک ملک با فیلدهای داده درخواست شده:
- پایه (
displayName
، types
، openingHours
، formattedAddress
)
{ "includedTypes": ["school","transport","bus","convenience_store"],
"excludedTypes": ["lodging"], "includedPrimaryTypes":
["restaurant","tourist_attraction","airport"], "excludedPrimaryTypes":
["lodging"], "maxResultCount": 20, "locationRestriction": { "circle": {
"center": { "latitude": 37.7937, "longitude": -122.3965 }, "radius": 500.0 } } }
3. تعامل را با Dynamic Maps and Directions API اضافه کنید
- بخش و مراحل بهروز با پرس و جوی Directions API . * از زمان در بخش بعدی استفاده کنید.

توضیحات : displayName
, types
, rating
, userRatingCount
, priceLevel
.
زمان : از جستار قبلی Directions API.
نظرات : reviews[i].author
، reviews[i].rating
، reviews[i].text
.
تصاویر : در طول پیشنمایش نامحدود Nearby Search (جدید) API ، باید جزئیات مکانها را با place.id
پرس و جو کنید تا photo_reference را دریافت کنید و سپس در تجربه خود یکی یکی پرس و جو کنید.

تعداد پرس و جوها و هزینه مرتبط
نتیجه گیری
تجربه کشف محلی یک راه قدرتمند برای ارائه ارزش کاربر است. این پیادهسازی نمایشی دارای ویژگیهای زیادی است که احتمالاً هنگام ایجاد چنین تجربهای در پلتفرم Google Maps با قابلیتهای ویژه از Nearby Search (جدید) API شامل میشود.
مراحل بعدی
پیشنهاد مطالعه بیشتر:
مشارکت کنندگان
نویسندگان اصلی:
توماس آنگلرت | مهندس راه حل های پلتفرم نقشه های گوگل
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-27 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis document demonstrates how to build a local discovery experience using the Nearby Search (New) API, enhancing user engagement with interactive maps and relevant place recommendations.\u003c/p\u003e\n"],["\u003cp\u003eLocal discovery experiences benefit users by offering discovery of nearby points of interest, interactive place selection and dynamic data refresh, and visualizations with reviews, photos, and travel times.\u003c/p\u003e\n"],["\u003cp\u003eThis guide presents a custom local discovery implementation leveraging Google Maps Platform APIs including Nearby Search (New) API, Places Autocomplete, Directions API, and Place Photo API for detailed place information.\u003c/p\u003e\n"],["\u003cp\u003eThe example application showcases the process of location search using Autocomplete, retrieving local points of interest with Nearby Search (New) API, adding interactivity with Dynamic Maps and Directions API, and displaying detailed place information upon interaction.\u003c/p\u003e\n"],["\u003cp\u003eCost considerations are outlined, highlighting API usage and billing based on the specific Google Maps Platform products involved in the local discovery experience.\u003c/p\u003e\n"]]],["This document details how to create a local discovery experience using Google Maps Platform APIs. Key actions include using the **Nearby Search (New) API** to surface relevant places near a specified location, filtering results with `includedTypes`, `excludedTypes`, `includedPrimaryTypes`, and `excludedPrimaryTypes`, and `locationRestriction`. The experience is enriched by using **Places Autocomplete**, **Directions API**, and **Places Details** for interactivity, detailed information, and visuals. Cost and billing considerations are also outlined for each API used.\n"],null,["In this document, you will look into how to use [Nearby Search (New) API](https://developers.google.com/maps/documentation/places/web-service/search-nearby-new)to\nbuild a simple and cost effective\n\nlocal discovery experience.\n\nA local discovery experience shows users key places of interest near a location\nyou specify when searching for a hotel or a real estate. It often consists of an\ninteractive map, with an additional panel containing a place chooser and a\ngallery of photos. You will be presented with different Google Maps Platform\nproducts and capabilities to enhance the experience with interactivity.\n\nUse Cases\n\nNow let's understand what elements of the local discovery integration drive user\nvalue:\n\n- **Discovery** - Give users an overview of what is around a single location\n by surfacing relevant places of various types.\n\n- **Interactivity** - Empower users to select a place and dynamically refresh the data\n\n relative to that place.\n- **Visualization** - Provide places reviews, photos\n\n and walking time and distance for the users to quickly understand if it fits\n their needs.\n\nReference Architecture\n\nLocal Discovery\n\nThere are many ways to create a local discovery experience. The following\nintegration is a **custom example** of a user experience that leverages well\nknown Google Maps Platform APIs as well as some exciting new features. If you\nwish to have a templated approach to local discovery you can use [Web\nComponents](https://github.com/googlemaps/extended-component-library/tree/main/place_overview).\n\nSample Application\n\nSample Walkthrough\n\nYou will find in the table below the sample application broken into steps\ntogether with a description of the technical implementation with Google Maps\nPlatform APIs.\n\n1. Location Search with AutocompleteSearch location\n\n- Load **Maps Javascript API**.\n- **Places Autocomplete** query or pick location on the map.\n\n2. Surface local points of interest using **[Nearby Search (New) API](https://developers.google.com/maps/documentation/places/web-service/search-nearby-new)**\n\n- Popularity ranking (more relevant results) or Distance ranking.\n- `includedTypes`, `excludedTypes` ; if you are a hotel you can exclude \"lodging\" type, and include only suited types, ie: \"restaurant, cafe, park, tourit_attraction\".\n- Leverage `includedPrimaryTypes`, `excludedPrimaryTypes` for even more control over results.\n- \\`locationRestriction to avoid insufficient number of results or too far away places ; in case of ZERO results, broaden the circle / rectangle size prior to display results.\n\nQuery sample when **booking a hotel** with Data fields requested:\n\n- Basic (`displayName`, `types`, `openingHours`, `formattedAddress`)\n- Contact (`websiteUri`, `nationalPhoneNumber`, `internationalPhoneNumber`)\n- Preferred (`reviews`, `priceLevel`, `userRatingCount`)\n\n```scdoc\n { \"includedTypes\": [\"restaurant\",\"cafe\",\"park\"], \"excludedTypes\":\n[\"lodging\",\"convenience_store\"], \"includedPrimaryTypes\":\n[\"restaurant\",\"tourist_attraction\",\"airport\"], \"excludedPrimaryTypes\":\n[\"lodging\"], \"maxResultCount\": 20, \"locationRestriction\": { \"circle\": {\n\"center\": { \"latitude\": 37.7937, \"longitude\": -122.3965 }, \"radius\": 500.0 } } }\n```\n\nQuery sample when **searching a real estate** with Data fields requested:\n\n- Basic (`displayName`, `types`, `openingHours`, `formattedAddress`)\n\n```scdoc\n { \"includedTypes\": [\"school\",\"transport\",\"bus\",\"convenience_store\"],\n\"excludedTypes\": [\"lodging\"], \"includedPrimaryTypes\":\n[\"restaurant\",\"tourist_attraction\",\"airport\"], \"excludedPrimaryTypes\":\n[\"lodging\"], \"maxResultCount\": 20, \"locationRestriction\": { \"circle\": {\n\"center\": { \"latitude\": 37.7937, \"longitude\": -122.3965 }, \"radius\": 500.0 } } }\n```\n\n3. Add **interactivity** with Dynamic Maps and Directions API\n\n- Up to date **leg and steps** by querying **[Directions\n API](https://developers.google.com/maps/documentation/directions/overview)**. \\* Use time in the next section.\n\n4. Display detailed information of the place upon interaction\n\n1. **Description** : `displayName`, `types`, `rating`, `userRatingCount`,\n `priceLevel`.\n\n **Time**: coming from the previous Directions API query.\n2. **Reviews** : `reviews[i].author`, `reviews[i].rating`,`reviews[i].text`.\n\n3. **Images** : during *Unrestricted Preview of Nearby Search (New) API* , you\n will have to query [Places\n Details](https://developers.google.com/maps/documentation/places/web-service/details)\n with [place.id](http://place.id) to get\n [photo_reference](https://developers.google.com/maps/documentation/places/web-service/details#Place-photos)\n to then query one at a time in your experience\n\nQueries count and cost associated\n\n- [Maps JavaScript\n API](https://developers.google.com/maps/documentation/javascript/usage-and-billing#pricing-for-product): 1 map at load of the experience.\n- Places Autocomplete API: 1 query every character typed (if using the [Autocomplete\n Widget](https://developers.google.com/maps/documentation/javascript/place-autocomplete)), it can be customised.\n- [Nearby Search (New)\n API](https://developers.google.com/maps/documentation/places/web-service/search-nearby-new): 1 query every 20 places displayed. Different billing according to [Place\n data](https://developers.google.com/maps/documentation/places/web-service/usage-and-billing#data-skus) that are part of the query response.\n- [Directions\n API](https://developers.google.com/maps/documentation/directions/usage-and-billing#pricing-for-product): 1 query every place selected by the user.\n- [Place Photo\n API](https://developers.google.com/maps/documentation/places/web-service/usage-and-billing#places-photo-new-ent-sku): 1 query every photo displayed.\n\nConclusion\n\nA local discovery experience is a powerful way to deliver user value. This\ndemonstration implementation has many features you are likely to include when\ncreating such an experience on Google Maps Platform with special capabilities\nfrom the [Nearby Search (New) API](https://developers.google.com/maps/documentation/places/web-service/search-nearby-new).\n\nNext Steps\n\nSuggested further reading:\n\n- [Web Components in the Maps JavaScript API](https://developers.google.com/maps/documentation/web-components/overview)\n- [Places Autocomplete Optimization](https://developers.google.com/maps/documentation/places/web-service/autocomplete#best-practices)\n- Other [Places Services](https://developers.google.com/maps/documentation/places/web-service/overview)\n- Leave feedback below.\n\nContributors\n\nPrincipal authors:\n\n[Thomas Anglaret](https://www.linkedin.com/in/thomas-anglaret/) \\| Google Maps\nPlatform Solutions Engineer"]]