maps_direction_walking_by_coordinates
Plan walking routes up to 100km using coordinate-based navigation. Get distance, duration, and detailed directions for pedestrian commuting between start and end points.
Instructions
步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据
Args:
origin (str): 起点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909")
destination (str): 终点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909")
Returns:
Dict[str, Any]: 包含距离、时长和详细导航信息的路线数据
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| origin | Yes | ||
| destination | Yes |
Input Schema (JSON Schema)
{
"properties": {
"destination": {
"title": "Destination",
"type": "string"
},
"origin": {
"title": "Origin",
"type": "string"
}
},
"required": [
"origin",
"destination"
],
"type": "object"
}
Implementation Reference
- amap_mcp_server/server.py:311-363 (handler)The handler function implementing the maps_direction_walking_by_coordinates tool. It makes an API request to AMap's walking direction endpoint using provided coordinates and processes the response into a structured route format.@mcp.tool() def maps_direction_walking_by_coordinates(origin: str, destination: str) -> Dict[str, Any]: """步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据 Args: origin (str): 起点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909") destination (str): 终点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909") Returns: Dict[str, Any]: 包含距离、时长和详细导航信息的路线数据 """ try: response = requests.get( "https://restapi.amap.com/v3/direction/walking", params={ "key": AMAP_MAPS_API_KEY, "origin": origin, "destination": destination } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"Direction Walking failed: {data.get('info') or data.get('infocode')}"} paths = [] for path in data["route"]["paths"]: steps = [] for step in path["steps"]: steps.append({ "instruction": step.get("instruction"), "road": step.get("road"), "distance": step.get("distance"), "orientation": step.get("orientation"), "duration": step.get("duration") }) paths.append({ "distance": path.get("distance"), "duration": path.get("duration"), "steps": steps }) return { "route": { "origin": data["route"]["origin"], "destination": data["route"]["destination"], "paths": paths } } except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}
- amap_mcp_server/server.py:311-311 (registration)The @mcp.tool() decorator registers this function as an MCP tool.@mcp.tool()
- amap_mcp_server/server.py:312-321 (schema)Type hints and docstring define the input schema (origin and destination as strings in 'lon,lat' format) and output schema (Dict with route information).def maps_direction_walking_by_coordinates(origin: str, destination: str) -> Dict[str, Any]: """步行路径规划 API 可以根据输入起点终点经纬度坐标规划100km 以内的步行通勤方案,并且返回通勤方案的数据 Args: origin (str): 起点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909") destination (str): 终点经纬度坐标,格式为"经度,纬度" (例如:"116.434307,39.90909") Returns: Dict[str, Any]: 包含距离、时长和详细导航信息的路线数据 """