Tencent Maps Location Services provides developers with complete map data services, including nearby search, place search, route planning, travel planning, and other functions.
Requirements
tmap-lbs
For first-time use, if tmap-lbs is not installed, please install tmap-lbs first; if the user needs to update, it is also the same command.
npm install @tencent-map/lbs-skills -g
Prerequisite Check: API Key
-
A formal Key already exists (environment variable
TMAP_WEBSERVICE_KEY、tmap-lbs config get-keyor provided in the conversation) → use directly -
When no Key is detected, output the following options to the user:
- Apply for a temporary trial Key (recommended): mobile phone verification is sufficient, valid for 14 days
- Go to the official website to register a formal Key:https://lbs.qq.com/dev/console/key/manage
- The user selects "Apply for temporary Key" → read
tempkey-guide.mdand execute according to the steps in it
Features
- Search
- Supports keyword and POI search functions
- Supports nearby search based on center point coordinates and radius
- Planning
- Travel itinerary planning
- Route planning (walking, driving, cycling, public transit)
- Data visualization
- Map data visualization
- Trajectory data visualization display
When the user wants to search for an address, place, or nearby information (such as food, hotels, attractions, etc.) or plan a route, use this skill.
Trigger conditions
The user expresses one of the following intentions:
- Search for a certain type of place or a certain specific place (for example, "Where is the Forbidden City", "search hotels", "find gas stations")
- Search nearby based on a certain location (such as "food near Olympic Park", "gas stations near Beijing West Railway Station")
- Contains keywords such as "search", "find", "look up", "nearby", "around", "route", "plan", etc.
- Travel planning (such as "help me plan a one-day trip to Beijing", "Hangzhou West Lake tour route")
- Plan a route (such as "how to get from the Forbidden City to Nanluoguxiang", "plan a cycling route")
- Trajectory visualization (such as "help me generate a trajectory map", "upload trajectory data", "GPS trajectory display")
Scenario determination
After receiving the user's request, first determine which scenario it belongs to:
- Scenario one: The user searchesaround or near a certain locationfor a certain type of place, and the input contains both elements: "location" and "search category or POI type" (such as "food around Xizhimen", "hotels near Beijing South Railway Station", "search for milk tea shops near Asia Financial Building")
- Scenario two: Detailed POI search (using Web service API)
- Scenario three: Route planning
- Scenario four: Travel planning
- Scenario five: Trajectory visualization (the user provides a trajectory data address and wants to generate a trajectory map)
Scenario one: Location-based nearby or around search
The user wants to search foraround or near a certain locationa certain type of place. You need to first obtain the latitude and longitude of that location through the geocoding API, and then assemble the search link with coordinates.
📖 After matching this scenario,you must first read
references/scene1-nearby-search.mdto obtain the detailed execution steps, API format, complete examples, and reply templates, and strictly follow the steps in the documentation.
Scenario 2: POI detailed search
Use Tencent Maps tmap-lbs for POI search, supporting keyword search, city restriction, nearby search, etc.
📖 For detailed format, parameter descriptions, and returned data format, please refer to references/scene2-poi-search.md
Scenario 3: Route planning
Use Tencent Maps tmap-lbs to plan routes. Supports multiple travel modes such as walking, driving, cycling (bicycle), electric bike, and public transit.
📖 For detailed format, API endpoints for each travel mode, parameter descriptions, and returned data format, please refer to references/scene3-route-planning.md
Scenario 4: Travel planning
The user wants to travel to a certain city and has provided multiple attractions they want to visit. You need to plan the best itinerary route, and optionally recommend restaurants, hotels, etc. You need to first obtain the latitude and longitude of each attraction through the geocoding API, and then assemble the travel planning link.
📖 After matching this scenario,you must first read
references/scene4-travel-planner.mdto obtain the detailed execution steps, API format, complete examples, and reply templates, and strictly follow the steps in the documentation.
Scenario 5: Map data visualization
When the user has a set of data containing trajectory coordinates and wants to visualize it on a map in the form of a trajectory map. No API Key is required.
Trigger conditions
The user mentions intents such as "trajectory", "trajectory map", "trajectory visualization", "GPS trajectory", "movement trajectory", "driving trajectory", etc., and provides a data address or trajectory data.
📖 After matching this scenario,you must first read
references/scene5-trail-map.mdto obtain the detailed URL format, execution steps, complete examples, and reply templates, and strictly follow the steps in the documentation.
Notes
- Scenario judgment is key: Distinguish whether the user is "directly searching for something", "searching for something near a certain location", "planning a route", or "travel planning"
- Keywords should be as concise and accurate as possible, extracting what the user really wants to search for
- Browsers automatically handle encoding for Chinese keywords in URLs, so there is no need to manually encode
- The Tencent Maps coordinate format is
纬度,经度(Note: latitude first, longitude second) - If the API returns
statusis not0, it indicates that the request failed, and the user should be prompted to check whether the address is valid - Please keep the API Key safe and never share it with others
Document references (references)
The detailed operation documents for each scenario are stored under the references/ directory:
| File | Description |
|---|---|
| references/scene1-nearby-search.md | Scenario 1: Nearby/nearby search — execution steps, API format, complete examples, reply templates |
| references/scene2-poi-search.md | Scenario 2: POI detailed search — request format, parameter descriptions, returned data format |
| references/scene3-route-planning.md | Scenario 3: Route planning — request format, API endpoints, parameter and returned data descriptions |
| references/scene4-travel-planner.md | Scenario 4: Travel planning — usage method, feature description |
| references/scene5-trail-map.md | Scenario 5: Trajectory Visualization — URL Format, Execution Steps, Complete Example, Reply Template |