Skip to main content
Glama

maps_distance

Calculate distance between coordinates using driving, walking, or spherical distance measurements for route planning and location analysis.

Instructions

测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量

Input Schema

NameRequiredDescriptionDefault
originsYes
destinationYes
typeNo1

Input Schema (JSON Schema)

{ "properties": { "destination": { "title": "Destination", "type": "string" }, "origins": { "title": "Origins", "type": "string" }, "type": { "default": "1", "title": "Type", "type": "string" } }, "required": [ "origins", "destination" ], "type": "object" }

Implementation Reference

  • The maps_distance tool handler: measures distance between origins and destination coordinates using Amap API, supports driving, walking, and spherical distance types. Registered via @mcp.tool() decorator.
    @mcp.tool() def maps_distance(origins: str, destination: str, type: str = "1") -> Dict[str, Any]: """测量两个经纬度坐标之间的距离,支持驾车、步行以及球面距离测量""" try: response = requests.get( "https://restapi.amap.com/v3/distance", params={ "key": AMAP_MAPS_API_KEY, "origins": origins, "destination": destination, "type": type } ) response.raise_for_status() data = response.json() if data["status"] != "1": return {"error": f"Direction Distance failed: {data.get('info') or data.get('infocode')}"} results = [] for result in data["results"]: results.append({ "origin_id": result.get("origin_id"), "dest_id": result.get("dest_id"), "distance": result.get("distance"), "duration": result.get("duration") }) return {"results": results} except requests.exceptions.RequestException as e: return {"error": f"Request failed: {str(e)}"}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sugarforever/amap-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server