677 lines
20 KiB
JSON
677 lines
20 KiB
JSON
{
|
||
"openapi": "3.0.0",
|
||
"info": {
|
||
"title": "OpenStreetMap地图服务",
|
||
"version": "1.0.0",
|
||
"description": "基于OpenStreetMap的地图可视化服务API,支持在地图上添加标记点、绘制圆形区域、创建和管理告警信息。所有地图元素存储在服务器端,支持通过iframe嵌入到其他网站中。",
|
||
"contact": {
|
||
"name": "API Support"
|
||
},
|
||
"license": {
|
||
"name": "MIT"
|
||
}
|
||
},
|
||
"servers": [
|
||
{
|
||
"url": "http://localhost:3000",
|
||
"description": "开发服务器"
|
||
}
|
||
],
|
||
"tags": [
|
||
{
|
||
"name": "Map",
|
||
"description": "地图可视化操作接口"
|
||
}
|
||
],
|
||
"paths": {
|
||
"/api/marker": {
|
||
"get": {
|
||
"summary": "在地图上添加标记点",
|
||
"description": "在服务器端存储一个标记点,并根据指定的经纬度坐标在地图上添加该标记,支持自定义图标和弹窗标题。标记数据存储在服务器内存中,可通过 /api/markers 获取所有标记。",
|
||
"tags": ["Map"],
|
||
"parameters": [
|
||
{
|
||
"name": "lat",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -90,
|
||
"maximum": 90
|
||
},
|
||
"description": "纬度坐标,范围 -90 到 90"
|
||
},
|
||
{
|
||
"name": "lng",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -180,
|
||
"maximum": 180
|
||
},
|
||
"description": "经度坐标,范围 -180 到 180"
|
||
},
|
||
{
|
||
"name": "icon",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "自定义图标URL,默认为OpenStreetMap默认图标"
|
||
},
|
||
{
|
||
"name": "title",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "标记点的弹窗标题,鼠标悬停时显示"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "标记点添加成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
},
|
||
"type": {
|
||
"type": "string"
|
||
},
|
||
"data": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"lat": {
|
||
"type": "number"
|
||
},
|
||
"lng": {
|
||
"type": "number"
|
||
},
|
||
"icon": {
|
||
"type": "string"
|
||
},
|
||
"title": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true,
|
||
"type": "marker",
|
||
"data": {
|
||
"id": "1743168000000",
|
||
"lat": 39.9042,
|
||
"lng": 116.4074,
|
||
"icon": "default",
|
||
"title": "北京天安门"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数错误",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"error": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"error": "Missing required parameters: lat and lng"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/markers": {
|
||
"get": {
|
||
"summary": "获取所有标记点",
|
||
"description": "返回服务器端存储的所有标记点列表",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "标记列表获取成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"markers": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"lat": {
|
||
"type": "number"
|
||
},
|
||
"lng": {
|
||
"type": "number"
|
||
},
|
||
"icon": {
|
||
"type": "string"
|
||
},
|
||
"title": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"markers": [
|
||
{
|
||
"id": "1743168000000",
|
||
"lat": 39.9042,
|
||
"lng": 116.4074,
|
||
"icon": "default",
|
||
"title": "北京天安门"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/markers/clear": {
|
||
"post": {
|
||
"summary": "清除所有标记点",
|
||
"description": "清除服务器端存储的所有标记点",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "标记点清除成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/circle": {
|
||
"get": {
|
||
"summary": "在地图上绘制圆形区域",
|
||
"description": "在服务器端存储一个圆形区域,并根据指定的经纬度坐标和半径在地图上绘制该圆形。圆心位置可选显示标记点。圆形数据存储在服务器内存中,可通过 /api/circles 获取所有圆形。",
|
||
"tags": ["Map"],
|
||
"parameters": [
|
||
{
|
||
"name": "lat",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -90,
|
||
"maximum": 90
|
||
},
|
||
"description": "圆心纬度坐标,范围 -90 到 90"
|
||
},
|
||
{
|
||
"name": "lng",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -180,
|
||
"maximum": 180
|
||
},
|
||
"description": "圆心经度坐标,范围 -180 到 180"
|
||
},
|
||
{
|
||
"name": "radius",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": 1
|
||
},
|
||
"description": "圆的半径,单位为米,必须大于0"
|
||
},
|
||
{
|
||
"name": "icon",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "圆心位置的自定义图标URL"
|
||
},
|
||
{
|
||
"name": "title",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "圆心标记点的弹窗标题"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "圆形区域绘制成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
},
|
||
"type": {
|
||
"type": "string"
|
||
},
|
||
"data": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"lat": {
|
||
"type": "number"
|
||
},
|
||
"lng": {
|
||
"type": "number"
|
||
},
|
||
"radius": {
|
||
"type": "number"
|
||
},
|
||
"icon": {
|
||
"type": "string"
|
||
},
|
||
"title": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true,
|
||
"type": "circle",
|
||
"data": {
|
||
"id": "1743168000001",
|
||
"lat": 39.9042,
|
||
"lng": 116.4074,
|
||
"radius": 1000,
|
||
"icon": "default",
|
||
"title": "北京市中心区域"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数错误",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"error": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"error": "Invalid radius: must be a positive number"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/circles": {
|
||
"get": {
|
||
"summary": "获取所有圆形区域",
|
||
"description": "返回服务器端存储的所有圆形区域列表",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "圆形列表获取成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"circles": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"lat": {
|
||
"type": "number"
|
||
},
|
||
"lng": {
|
||
"type": "number"
|
||
},
|
||
"radius": {
|
||
"type": "number"
|
||
},
|
||
"icon": {
|
||
"type": "string"
|
||
},
|
||
"title": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"circles": [
|
||
{
|
||
"id": "1743168000001",
|
||
"lat": 39.9042,
|
||
"lng": 116.4074,
|
||
"radius": 1000,
|
||
"icon": "default",
|
||
"title": "北京市中心区域"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/circles/clear": {
|
||
"post": {
|
||
"summary": "清除所有圆形区域",
|
||
"description": "清除服务器端存储的所有圆形区域",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "圆形区域清除成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/alert": {
|
||
"post": {
|
||
"summary": "创建告警信息",
|
||
"description": "在服务器端创建一条告警,告警会以不同颜色的弹窗样式显示在地图界面中,支持danger/warning/info/success四种类型。告警存储在服务器内存中。",
|
||
"tags": ["Map"],
|
||
"parameters": [
|
||
{
|
||
"name": "message",
|
||
"in": "query",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "告警的文本内容"
|
||
},
|
||
{
|
||
"name": "type",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string",
|
||
"enum": ["danger", "warning", "info", "success"],
|
||
"default": "danger"
|
||
},
|
||
"description": "告警类型:danger(红色)、warning(橙色)、info(蓝色)、success(绿色),默认为danger"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "告警创建成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
},
|
||
"alert": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"message": {
|
||
"type": "string"
|
||
},
|
||
"type": {
|
||
"type": "string"
|
||
},
|
||
"timestamp": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true,
|
||
"alert": {
|
||
"id": "1743168000000",
|
||
"message": "前方道路施工",
|
||
"type": "warning",
|
||
"timestamp": "2026-03-28T12:00:00.000Z"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "参数错误",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"error": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"error": "Missing required parameter: message"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/alerts": {
|
||
"get": {
|
||
"summary": "获取所有告警信息",
|
||
"description": "返回服务器端存储的所有告警信息列表",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "告警列表获取成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"alerts": {
|
||
"type": "array",
|
||
"items": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"type": "string"
|
||
},
|
||
"message": {
|
||
"type": "string"
|
||
},
|
||
"type": {
|
||
"type": "string"
|
||
},
|
||
"timestamp": {
|
||
"type": "string"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"alerts": [
|
||
{
|
||
"id": "1743168000000",
|
||
"message": "前方道路施工",
|
||
"type": "warning",
|
||
"timestamp": "2026-03-28T12:00:00.000Z"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/alerts/clear": {
|
||
"post": {
|
||
"summary": "清除所有告警信息",
|
||
"description": "清除服务器端存储的所有告警信息",
|
||
"tags": ["Map"],
|
||
"responses": {
|
||
"200": {
|
||
"description": "告警清除成功",
|
||
"content": {
|
||
"application/json": {
|
||
"schema": {
|
||
"type": "object",
|
||
"properties": {
|
||
"success": {
|
||
"type": "boolean"
|
||
}
|
||
}
|
||
},
|
||
"example": {
|
||
"success": true
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/api/embed": {
|
||
"get": {
|
||
"summary": "获取可嵌入的地图页面",
|
||
"description": "返回一个完整的、可嵌入的HTML地图页面。通过iframe方式嵌入到其他网站,页面会自动轮询获取服务器端存储的标记点、圆形区域和告警信息并显示在地图上。",
|
||
"tags": ["Map"],
|
||
"parameters": [
|
||
{
|
||
"name": "lat",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -90,
|
||
"maximum": 90
|
||
},
|
||
"description": "地图初始化时的中心纬度(此参数已弃用,地图会自动显示所有标记点)"
|
||
},
|
||
{
|
||
"name": "lng",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "number",
|
||
"minimum": -180,
|
||
"maximum": 180
|
||
},
|
||
"description": "地图初始化时的中心经度"
|
||
},
|
||
{
|
||
"name": "icon",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "初始标记点的自定义图标URL"
|
||
},
|
||
{
|
||
"name": "title",
|
||
"in": "query",
|
||
"required": false,
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"description": "初始标记点的弹窗标题"
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "嵌入用HTML页面",
|
||
"content": {
|
||
"text/html": {
|
||
"schema": {
|
||
"type": "string"
|
||
},
|
||
"example": "<!DOCTYPE html><html><head>...</head><body><div id=\"map\"></div>...</body></html>"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|