8
n8n 中文网amn8n.com

🚛🗺️ 使用 Open Route API 和 Google Sheets 进行物流地理编码

中级

这是一个IT Ops领域的自动化工作流,包含 9 个节点。主要使用 Set, Wait, HttpRequest, GoogleSheets, ManualTrigger 等节点。 🚛🗺️ 使用 Open Route API 和 Google Sheets 进行物流地理编码

前置要求
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": ""
  },
  "nodes": [
    {
      "id": "b1d00cd4-b9e8-4d84-b580-08368fbb9396",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 540,
        "height": 640,
        "content": "### 1. 触发工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "32f84996-0480-4c0b-aab7-3f5ebca9dd4e",
      "name": "当点击\"测试工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        60,
        260
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fe628240-0550-42dd-a375-7ecba134fd6c",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        600,
        -160
      ],
      "parameters": {
        "color": 7,
        "width": 1120,
        "height": 640,
        "content": "### 2. 循环收集 GPS 坐标"
      },
      "typeVersion": 1
    },
    {
      "id": "eac06796-f40d-4c94-96b2-4ad672053295",
      "name": "收集地址",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        340,
        260
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1232640606,
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "13198c2c-cdca-4a5e-893a-1fac24090f33",
      "name": "查询 Open Route API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        960,
        280
      ],
      "parameters": {
        "url": "https://api.openrouteservice.org/geocode/search",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "api_key"
            },
            {
              "name": "text",
              "value": "={{ $json.address }}"
            },
            {
              "name": "boundary.country",
              "value": "={{ $json.country }}"
            },
            {
              "name": "sources",
              "value": "openstreetmap"
            },
            {
              "name": "size",
              "value": "1"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json; charset=utf-8"
            },
            {
              "name": "Accept",
              "value": "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "d0ad6f7e-8049-45c4-8022-8c16a8f71392",
      "name": "循环遍历地址",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        760,
        260
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "c84f27c6-3905-455a-b8a7-bb1d6bffafe0",
      "name": "保存结果",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1380,
        280
      ],
      "parameters": {
        "columns": {
          "value": {
            "id": "={{ $('Loop Over Addresses').item.json.id }}",
            "borough": "={{ $json.borough }}",
            "latitude": "={{ $json.latitude }}",
            "longitude": "={{ $json.longitude }}",
            "localadmin": "={{ $json.localadmin }}",
            "neighbourhood": "={{ $json.neighbourhood }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "id",
              "defaultMatch": true,
              "canBeUsedToMatch": true
            },
            {
              "id": "country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "longitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "longitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "latitude",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "latitude",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "borough",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "borough",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "neighbourhood",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "neighbourhood",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "localadmin",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "localadmin",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "id"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1232640606,
          "cachedResultUrl": "",
          "cachedResultName": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultUrl": "",
          "cachedResultName": ""
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.6
    },
    {
      "id": "6fa85604-4db7-431d-b0fd-b6cbb1773c12",
      "name": "提取结果",
      "type": "n8n-nodes-base.set",
      "position": [
        1180,
        280
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "e4c92077-f294-4e49-8276-20d1441c0c2c",
              "name": "longitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[0] }}"
            },
            {
              "id": "899e5304-e7a1-4ce1-bf9a-f403d74934fb",
              "name": "latitude",
              "type": "string",
              "value": "={{ $json.features[0].geometry.coordinates[1] }}"
            },
            {
              "id": "5b35642b-dda4-42b8-b7bb-1275616bfb59",
              "name": "borough",
              "type": "string",
              "value": "={{ $json.features[0].properties.borough }}"
            },
            {
              "id": "aa74bd9a-f543-48e1-a69b-0e6472bda053",
              "name": "neighbourhood",
              "type": "string",
              "value": "={{ $json.features[0].properties.neighbourhood }}"
            },
            {
              "id": "7f303dc8-4e28-4d46-8e3e-9db00dbcac3a",
              "name": "localadmin",
              "type": "string",
              "value": "={{ $json.features[0].properties.localadmin }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "71c85728-f291-4a67-8d0d-8c7fcd38905d",
      "name": "5 秒",
      "type": "n8n-nodes-base.wait",
      "position": [
        1560,
        280
      ],
      "webhookId": "6ecebf96-14ed-4c7b-b467-eb48c143408e",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "7ca2b5ea-9af8-425d-958e-2f6ffe01656e",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        500
      ],
      "parameters": {
        "width": 580,
        "height": 380,
        "content": "### [查看教程](https://www.youtube.com/watch?v=IlblIlKcL0k)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "5 sec": {
      "main": [
        [
          {
            "node": "Loop Over Addresses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Results": {
      "main": [
        [
          {
            "node": "5 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Results": {
      "main": [
        [
          {
            "node": "Save Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Addresses": {
      "main": [
        [
          {
            "node": "Loop Over Addresses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Addresses": {
      "main": [
        [],
        [
          {
            "node": "Query Open Route API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Open Route API": {
      "main": [
        [
          {
            "node": "Extract Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Collect Addresses",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Samir Saci

Samir Saci

@samirsaci

Automation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci

外部链接
在 n8n.io 查看

分享此工作流