V2版本 支持多设备(与V1不兼容)
截图
NodeRED流
记得把自己的账号密码填进去
[
{
"id": "2f5a21f5.40c4de",
"type": "function",
"z": "6c436749.aaa108",
"name": "账号密码",
"func": "const account = '账号'\nconst password = '密码'\n//- 下面别改了 --------------------------------------------\nconst cid = '19082'\nconst time = parseInt(new Date().getTime() / 1000, 10)\nmsg.cid = cid\nmsg.account = account\nmsg.password = password\nmsg.time = time\nif (!msg.final) {\n if (!msg.md5) {\n msg.payload = password\n }\n else {\n msg.payload = msg.md5 + time\n msg.final = true\n }\n node.send(msg)\n}",
"outputs": 1,
"noerr": 0,
"x": 290,
"y": 100,
"wires": [
[
"64fc1bc2.4b7f44"
]
]
},
{
"id": "64fc1bc2.4b7f44",
"type": "md5",
"z": "6c436749.aaa108",
"name": "",
"fieldToHash": "payload",
"fieldTypeToHash": "msg",
"hashField": "md5",
"hashFieldType": "msg",
"x": 430,
"y": 100,
"wires": [
[
"ec60514f.a03d1",
"2f5a21f5.40c4de"
]
]
},
{
"id": "ec60514f.a03d1",
"type": "function",
"z": "6c436749.aaa108",
"name": "拼接口",
"func": "if(msg.final) {\n msg.signature = msg.md5\n msg.url = `http://litin.gmiot.net/1/auth/access_token?method=loginByUsername&account=${msg.account}&time=${msg.time}&signature=${msg.signature}&cid=${msg.cid}`\n node.send(msg)\n}",
"outputs": 1,
"noerr": 0,
"x": 600,
"y": 100,
"wires": [
[
"44f891a.a2c037"
]
]
},
{
"id": "44f891a.a2c037",
"type": "http request",
"z": "6c436749.aaa108",
"name": "",
"method": "GET",
"ret": "obj",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"x": 790,
"y": 100,
"wires": [
[
"ed74840a.c8dc08"
]
]
},
{
"id": "ed74840a.c8dc08",
"type": "function",
"z": "6c436749.aaa108",
"name": "记录token",
"func": "const result = msg.payload\nif(result.success) {\n flow.set('access_token', result.data && result.data.access_token)\n flow.set('account', msg.account)\n node.status({text: '登录成功', fill: 'green'})\n}\nelse{\n node.status({text: `登录失败{JSON.stringify(result)}`, fill: 'red'})\n}\n",
"outputs": 1,
"noerr": 0,
"x": 950,
"y": 100,
"wires": [
[]
]
},
{
"id": "1912abe1.3a91f4",
"type": "function",
"z": "6c436749.aaa108",
"name": "拼接口",
"func": "const access_token = flow.get('access_token')\nconst account = flow.get('account')\nmsg.url = `http://litin.gmiot.net/1/account/monitor?access_token=${access_token}&target=${account}`\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 280,
"y": 210,
"wires": [
[
"5b2d0d5f.3b83f4"
]
],
"info": "```\n\nhttp://litin.gmiot.net/1/account/monitor?access_token=${access_token}&target=${account}\nhttp://litin.gmiot.net/1/tool/address?lang=zh-CN&access_token=${access_token}&lng=${lng}&lat=${lat}\nhttp://litin.gmiot.net/1/account/devinfo?access_token=${access_token}&target=${account}\n\n```"
},
{
"id": "5b2d0d5f.3b83f4",
"type": "http request",
"z": "6c436749.aaa108",
"name": "",
"method": "GET",
"ret": "obj",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"x": 440,
"y": 210,
"wires": [
[
"dfde813b.e22e9"
]
]
},
{
"id": "dfde813b.e22e9",
"type": "function",
"z": "6c436749.aaa108",
"name": "分支逻辑",
"func": "const result = msg.payload\nif(result.ret === 0) {\n node.status({text: '获取成功', fill: 'green'})\n node.send([msg,null])\n}else{\n node.status({text: `获取失败{JSON.stringify(result)}`, fill: 'red'})\n node.send([null, msg])\n}",
"outputs": 2,
"noerr": 0,
"x": 610,
"y": 210,
"wires": [
[
"bd3f32ea.fbf52"
],
[
"ece58ad0.3fa468",
"e91ae05a.1b5a9"
]
]
},
{
"id": "ece58ad0.3fa468",
"type": "link out",
"z": "6c436749.aaa108",
"name": "万物在线-失败重新登录out",
"links": [
"28fd3238.6343be"
],
"x": 745,
"y": 250,
"wires": []
},
{
"id": "28fd3238.6343be",
"type": "link in",
"z": "6c436749.aaa108",
"name": "万物在线-登录in",
"links": [
"ece58ad0.3fa468"
],
"x": 155,
"y": 100,
"wires": [
[
"2f5a21f5.40c4de"
]
]
},
{
"id": "e91ae05a.1b5a9",
"type": "delay",
"z": "6c436749.aaa108",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 790,
"y": 290,
"wires": [
[
"e3fb2d87.73964"
]
]
},
{
"id": "6e7d84a9.7bed5c",
"type": "link in",
"z": "6c436749.aaa108",
"name": "万物在线-获取信息in",
"links": [
"e3fb2d87.73964",
"b25cb7d2.6b3998"
],
"x": 155,
"y": 210,
"wires": [
[
"1912abe1.3a91f4"
]
]
},
{
"id": "e3fb2d87.73964",
"type": "link out",
"z": "6c436749.aaa108",
"name": "万物在线-重试获取信息out",
"links": [
"6e7d84a9.7bed5c"
],
"x": 905,
"y": 290,
"wires": []
},
{
"id": "dd0402a1.28d6e",
"type": "inject",
"z": "6c436749.aaa108",
"name": "定时获取",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "5",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"x": 100,
"y": 260,
"wires": [
[
"1912abe1.3a91f4"
]
]
},
{
"id": "bd3f32ea.fbf52",
"type": "link out",
"z": "6c436749.aaa108",
"name": "万物在线-获取信息out",
"links": [
"30cc557.a5cf0aa",
"8dee909.bdc037"
],
"x": 745,
"y": 200,
"wires": []
},
{
"id": "30cc557.a5cf0aa",
"type": "link in",
"z": "6c436749.aaa108",
"name": "万物在线-信息展示in",
"links": [
"bd3f32ea.fbf52"
],
"x": 155,
"y": 410,
"wires": [
[
"f8a41ae.10edee8"
]
]
},
{
"id": "f9166e8e.5275e",
"type": "inject",
"z": "6c436749.aaa108",
"name": "手动登录",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 60,
"wires": [
[
"2f5a21f5.40c4de"
]
]
},
{
"id": "f8a41ae.10edee8",
"type": "function",
"z": "6c436749.aaa108",
"name": "构建参数",
"func": "const result = msg.payload\nconst access_token = flow.get('access_token')\nlet monitors = result.data\nconst id = new Date().valueOf()\n\nmonitors.map((item, index) => {\n const {lat, lng} = item\n node.send({\n url: `http://litin.gmiot.net/1/tool/address?lang=zh-CN&access_token=${access_token}&lng=${lng}&lat=${lat}`,\n devices_info: item,\n payload: item,\n parts: {id, type: 'array', count: monitors.length, len: 1, index}\n })\n})\n\nnode.status({text:`最后更新{new Date().toLocaleTimeString('zh-cn',{timeZone: \"Asia/Chongqing\"})} 设备数量{monitors.length}`, fill: 'green'})",
"outputs": 1,
"noerr": 0,
"x": 280,
"y": 410,
"wires": [
[
"f98910a7.c09c5",
"904a8cb.2322b7"
]
]
},
{
"id": "db9c0ed.c1778f",
"type": "debug",
"z": "6c436749.aaa108",
"name": "完整信息",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 950,
"y": 470,
"wires": []
},
{
"id": "f98910a7.c09c5",
"type": "http request",
"z": "6c436749.aaa108",
"name": "",
"method": "GET",
"ret": "obj",
"paytoqs": false,
"url": "",
"tls": "",
"proxy": "",
"x": 440,
"y": 410,
"wires": [
[
"8a139a80.a910f8"
]
]
},
{
"id": "8a139a80.a910f8",
"type": "function",
"z": "6c436749.aaa108",
"name": "合并信息",
"func": "const address = msg.payload.address\nmsg.payload = Object.assign(msg.devices_info, {address})\nreturn msg",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 410,
"wires": [
[
"9f202169.562be"
]
]
},
{
"id": "9f202169.562be",
"type": "join",
"z": "6c436749.aaa108",
"name": "",
"mode": "auto",
"build": "array",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 780,
"y": 410,
"wires": [
[
"2904291f.a07686",
"db9c0ed.c1778f"
]
]
},
{
"id": "904a8cb.2322b7",
"type": "debug",
"z": "6c436749.aaa108",
"name": "转发调试",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 440,
"y": 470,
"wires": []
},
{
"id": "e6132b94.6ee488",
"type": "comment",
"z": "6c436749.aaa108",
"name": "帮助",
"info": "## V2与V1的区别\n\nV1不支持单账号多设备,V2支持\n\n## 账号密码相关\n\n本NR流支持万物在线的设备\n\n以能否登录`http://lite.gmiot.net/index.shtml` 这个网页版作为判断依据\n\n验证能登录网页版后,使用对应账号密码\n\n在“账号密码”节点进行填写相关信息\n\n## 转发给HA等设备\n\n如果不需要做逆地址转换(也就是经纬度转门牌号),可以使用自己的处理函数去替换“转发调试”,实际数据可以看调试信息\n",
"x": 280,
"y": 60,
"wires": []
},
{
"id": "2904291f.a07686",
"type": "ui_template",
"z": "6c436749.aaa108",
"group": "187aa0fc.84398f",
"name": "万物在线V2",
"order": 1,
"width": "6",
"height": "8",
"format": " <script type=\"text/x-template\" id=\"map_template\">\n <style>\n .map-container {\n color: #333;\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n\n .map,\n .panorama,\n .device-list {\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n\n\n .panorama,\n .panorama-bar,\n .device-list {\n display: none;\n }\n\n .device-list {\n background: #f4f4f4;\n }\n\n .device-list h3,\n .device-list h4,\n .device-list h5,\n .device-list em {\n font-weight: normal;\n font-style: normal;\n margin: 0;\n padding: 0;\n }\n\n .device-list h3 {\n margin: 0;\n color: #fff !important;\n font-weight: normal;\n background: #1894ff !important;\n font-size: 18px;\n line-height: 40px;\n }\n\n .device-list h3 svg {\n width: 18px;\n height: 18px;\n position: relative;\n top: 3px;\n margin-left: 20px;\n }\n\n .device-list h3 path {\n fill: #fff !important;\n }\n\n .device-list ul {\n list-style-type: none;\n margin: 0;\n padding: 0;\n }\n\n .device-list ul li {\n padding: 10px 20px;\n background: #fff;\n position: relative;\n }\n\n .device-list ul li:last-child::after {\n display: none;\n }\n\n .device-list ul li::after {\n content: '';\n position: absolute;\n height: 1px;\n left: 10px;\n right: 10px;\n bottom: 0;\n background: #e0e0e0;\n }\n\n .device-list h4 {\n padding-bottom: 8px;\n }\n\n .device-list h4 span {\n font-size: 12px;\n color: #666;\n }\n\n .device-list em {\n color: #666;\n margin: 10px 0;\n font-size: 14px;\n }\n\n\n .map-infomation {\n background: #fff;\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n box-sizing: border-box;\n padding: 10px;\n }\n\n .map-infomation h4,\n .map-infomation h5,\n .map-infomation em {\n font-style: normal;\n margin: 0;\n padding: 0;\n font-weight: normal;\n }\n\n .map-infomation h5 {\n color: #666;\n margin: 10px 0;\n }\n\n .map-infomation em {\n font-size: 14px;\n }\n\n .map-infomation span {\n font-size: 12px;\n color: #666;\n }\n\n .map-icon {\n position: absolute;\n border-radius: 10px;\n padding: 2px 10px;\n background: rgba(255, 255, 255, .8);\n box-shadow: 0 0 2px rgba(0, 0, 0, .4);\n }\n\n .map-icon.hover {\n background: rgba(200, 200, 200, .8);\n }\n\n .map-icon div {\n width: 24px;\n height: 24px;\n }\n\n .map-icon svg path {\n fill: #333 !important;\n }\n\n .map-icon label {\n text-align: center;\n display: block;\n font-size: 10px;\n }\n\n .map-icon-earth {\n right: 10px;\n top: 10px;\n }\n\n .map-icon-360 {\n top: 70px;\n right: 10px;\n }\n\n .map-icon-list {\n top: 130px;\n right: 10px;\n }\n\n .map-icon-exit {\n top: 10px;\n right: 10px;\n }\n </style>\n <div class=\"map-container\" id=\"map_container\">\n <div class=\"map\"></div>\n <div class=\"map-bar\">\n <div class=\"map-icon map-icon-earth\">\n <div>\n <svg viewBox=\"0 0 1024 1024\" width=\"100%\" height=\"100%\">\n <path\n d=\"M523.377778 955.733333C278.755556 955.733333 79.644444 756.622222 79.644444 512c0-244.622222 199.111111-443.733333 443.733334-443.733333S967.111111 267.377778 967.111111 512c0 244.622222-199.111111 443.733333-443.733333 443.733333z m0-849.54074C299.614815 106.192593 117.57037 288.237037 117.57037 512c0 223.762963 182.044444 405.807407 405.807408 405.807407C747.140741 917.807407 929.185185 735.762963 929.185185 512c0-223.762963-182.044444-405.807407-405.807407-405.807407z\"\n fill=\"\"></path>\n <path\n d=\"M523.377778 955.733333c-127.051852 0-225.659259-195.318519-225.659259-443.733333 0-248.414815 98.607407-443.733333 225.659259-443.733333S749.037037 263.585185 749.037037 512c0 248.414815-100.503704 443.733333-225.659259 443.733333z m0-849.54074c-102.4 0-187.733333 185.837037-187.733334 405.807407 0 219.97037 85.333333 405.807407 187.733334 405.807407s187.733333-185.837037 187.733333-405.807407c0-219.97037-87.22963-405.807407-187.733333-405.807407z\"\n fill=\"\"></path>\n <path\n d=\"M523.377778 352.711111c-117.57037 0-235.140741-30.340741-339.437037-87.22963-9.481481-5.688889-13.274074-17.066667-7.585185-26.548148 5.688889-9.481481 17.066667-13.274074 26.548148-7.585185 96.711111 53.096296 208.592593 81.540741 320.474074 81.540741 113.777778 0 223.762963-28.444444 322.37037-83.437037 9.481481-5.688889 20.859259-1.896296 26.548148 7.585185 5.688889 9.481481 1.896296 20.859259-7.585185 26.548148-104.296296 58.785185-221.866667 89.125926-341.333333 89.125926zM197.214815 805.925926c-7.585185 0-13.274074-3.792593-17.066667-9.481482-5.688889-9.481481-1.896296-20.859259 7.585185-26.548148 102.4-54.992593 218.074074-85.333333 333.748148-85.333333 115.674074 0 231.348148 28.444444 333.748149 83.437037 9.481481 5.688889 13.274074 17.066667 7.585185 26.548148-5.688889 9.481481-17.066667 13.274074-26.548148 7.585185-96.711111-53.096296-204.8-79.644444-314.785186-79.644444-109.985185 0-219.97037 28.444444-316.681481 79.644444-1.896296 3.792593-3.792593 3.792593-7.585185 3.792593z\"\n fill=\"\"></path>\n <path\n d=\"M948.148148 534.755556H98.607407c-11.377778 0-18.962963-7.585185-18.962963-18.962963s7.585185-18.962963 18.962963-18.962963H948.148148c11.377778 0 18.962963 7.585185 18.962963 18.962963s-9.481481 18.962963-18.962963 18.962963z\"\n fill=\"\"></path>\n </svg>\n </div>\n <label>卫星</label>\n </div>\n <div class=\"map-icon map-icon-360\">\n <div>\n <svg viewBox=\"0 0 1025 1024\" width=\"100%\" height=\"100%\">\n <path\n d=\"M939.496727 89.367273 89.809455 89.367273c-46.917818 0-84.968727 38.050909-84.968727 84.968727l0 679.749818c0 46.917818 38.050909 84.968727 84.968727 84.968727l849.687273 0c46.917818 0 84.968727-38.050909 84.968727-84.968727L1024.465455 174.336C1024.465455 127.418182 986.414545 89.367273 939.496727 89.367273L939.496727 89.367273zM981.992727 854.085818c0 23.482182-19.013818 42.496-42.496 42.496L89.809455 896.581818c-23.482182 0-42.496-19.013818-42.496-42.496L47.313455 174.336c0-23.482182 19.013818-42.496 42.496-42.496l849.687273 0c23.482182 0 42.496 19.013818 42.496 42.496L981.992727 854.085818 981.992727 854.085818zM302.219636 238.056727c-46.917818 0-84.968727 38.050909-84.968727 84.968727s38.050909 84.968727 84.968727 84.968727c46.917818 0 84.968727-38.050909 84.968727-84.968727S349.160727 238.056727 302.219636 238.056727L302.219636 238.056727zM302.219636 365.521455c-23.482182 0-42.472727-19.013818-42.472727-42.496s19.013818-42.472727 42.472727-42.472727c23.482182 0 42.496 19.013818 42.496 42.472727S325.701818 365.521455 302.219636 365.521455L302.219636 365.521455z\">\n </path>\n <path\n d=\"M419.072 832.837818c0-164.235636 133.143273-297.402182 297.402182-297.402182 116.224 0 216.599273 66.839273 265.518545 164.002909l0-78.452364c-62.277818-77.963636-157.975273-128.046545-265.518545-128.046545-174.522182 0-318.161455 131.607273-337.501091 300.986182C336.151273 740.072727 270.196364 705.396364 196.026182 705.396364c-56.482909 0-108.288 20.061091-148.689455 53.434182l0 60.206545c35.048727-43.357091 88.599273-71.144727 148.689455-71.144727 90.949818 0 166.935273 63.581091 186.274909 148.689455l43.776 0C421.585455 876.032 419.072 854.737455 419.072 832.837818L419.072 832.837818z\">\n </path>\n </svg>\n </div>\n <label>全景</label>\n </div>\n <div class=\"map-icon map-icon-list\">\n <div>\n <svg viewBox=\"0 0 1024 1024\" width=\"100%\" height=\"100%\">\n <path\n d=\"M419.037 287.953h413.124c17.673 0 32-14.327 32-32s-14.327-32-32-32H419.037c-17.673 0-32 14.327-32 32s14.327 32 32 32z m-0.009 255.217h411.608c17.673 0 32-14.327 32-32s-14.327-32-32-32H419.028c-17.673 0-32 14.327-32 32s14.327 32 32 32z m413.133 192.632H419.037c-17.673 0-32 14.327-32 32s14.327 32 32 32h413.124c17.673 0 32-14.327 32-32s-14.327-32-32-32zM192.037 255.953a64 64 0 1 0 128 0 64 64 0 1 0-128 0zM192.037 510.787a64 64 0 1 0 128 0 64 64 0 1 0-128 0zM192.037 767.621a64 64 0 1 0 128 0 64 64 0 1 0-128 0z\"\n p-id=\"2732\"></path>\n </svg>\n </div>\n <label>列表</label>\n </div>\n <div class=\"map-infomation\">\n <h4></h4>\n <h5>卖力加载中...</h5>\n <em></em>\n </div>\n </div>\n <div class=\"device-list\">\n <h3>\n <svg viewBox=\"0 0 1024 1024\" width=\"100%\" height=\"100%\">\n <path\n d=\"M916.3 466.3H218.1l288.4-288.4c17.8-17.8 17.8-46.9 0-64.7-17.8-17.8-46.9-17.8-64.7 0L75.3 479.7c-17.8 17.8-17.8 46.9 0 64.7l366.5 366.5c17.8 17.8 46.9 17.8 64.7 0 17.8-17.8 17.8-46.9 0-64.7L218.1 557.7h698.2c25.2 0 45.7-20.6 45.7-45.7 0-25.2-20.6-45.7-45.7-45.7z\"\n fill=\"\" p-id=\"1945\"></path>\n </svg>\n 返回\n </h3>\n <ul></ul>\n </div>\n <div class=\"panorama\"></div>\n <div class=\"panorama-bar\">\n <div class=\"map-icon map-icon-exit\">\n <div>\n <svg viewBox=\"0 0 1024 1024\" width=\"100%\" height=\"100%\">\n <path\n d=\"M430.933333 665.6l59.733334 59.733333 213.333333-213.333333-213.333333-213.333333-59.733334 59.733333 110.933334 110.933333H128v85.333334h413.866667l-110.933334 110.933333zM810.666667 128H213.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333v170.666667h85.333333V213.333333h597.333334v597.333334H213.333333v-170.666667H128v170.666667c0 46.933333 38.4 85.333333 85.333333 85.333333h597.333334c46.933333 0 85.333333-38.4 85.333333-85.333333V213.333333c0-46.933333-38.4-85.333333-85.333333-85.333333z\">\n </path>\n </svg>\n </div>\n <label>退出</label>\n </div>\n </div>\n </div>\n </script>\n <script>\n async function main(node = {\n $watch() { }\n }) {\n // 在NR UI里,可能会重复初始化,避免多次初始化就刷新下吧\n if (window.map_inited) {\n location.reload()\n }\n window.map_inited = true\n let device_index = 0\n const rnd = new Date().valueOf()\n const storage_key = `access_token_${rnd}`\n const container_id = `map_container_${rnd}`\n let monitors = []\n let map, convertor, marker\n\n\n const readableTime = time => {\n const days = Math.floor(time / 3600 / 24)\n const hours = Math.floor(time / 3600 % 24)\n const minutes = Math.floor(time / 60 % 60)\n const seconds = Math.floor(time % 60)\n if (days > 0) {\n return `${days}天${hours}时`\n } else if (hours > 0) {\n return `${hours}时${minutes}分`\n } else if (minutes > 0) {\n return `${minutes}分${seconds}秒`\n } else {\n return `${seconds}秒`\n }\n }\n const readableInfo = monitor => {\n let info = ''\n if (monitor.device_info_new == 3) {\n info += `离线 ${readableTime(monitor.seconds)}`\n } else if (monitor.speed > 0) {\n info += `速度 ${monitor.speed}km/h`\n } else {\n info += `静止 ${readableTime(monitor.seconds)}`\n }\n return info\n }\n\n // 初始化容器\n const initContainer = () => {\n $('#map_template').after($('#map_template').html()).remove()\n $('#map_container').attr('id', container_id)\n }\n const initMap = () => {\n // 加载百度地图JS\n const panorama = new BMap.Panorama($('.panorama', `#${container_id}`).get(0))\n const panoramaService = new BMap.PanoramaService()\n const poi = new BMap.Point(116.404, 39.915)\n\n map = new BMap.Map($('.map', `#${container_id}`).get(0), {\n enableHighResolution: true\n })\n marker = new BMap.Marker(poi)\n convertor = new BMap.Convertor()\n\n map.centerAndZoom(poi, 16)\n map.enableScrollWheelZoom()\n map.addOverlay(marker)\n\n // 左侧放大缩小导航栏\n map.addControl(new BMap.NavigationControl({\n anchor: BMAP_ANCHOR_TOP_LEFT,\n type: BMAP_NAVIGATION_CONTROL_LARGE\n }))\n\n // 全景图由于H5版本的百度地图有毛病,故自己实现入口和退出\n $('.map-icon-360', `#${container_id}`).off('click').on('click', evt => {\n const monitor = monitors[device_index]\n panoramaService.getPanoramaByLocation(new BMap.Point(monitor.lng, monitor.lat), 1000, data =>\n panorama.setId(data.id))\n $('.panorama', `#${container_id}`).show()\n $('.panorama-bar', `#${container_id}`).show()\n })\n // 切换卫星视图模式\n $('.map-icon-earth', `#${container_id}`).off('click').on('click', evt => {\n if (map.getMapType() == BMAP_NORMAL_MAP) {\n map.setMapType(BMAP_HYBRID_MAP)\n $(evt.currentTarget).addClass('hover')\n } else {\n map.setMapType(BMAP_NORMAL_MAP)\n $(evt.currentTarget).removeClass('hover')\n }\n })\n // 退出全景\n $('.map-icon-exit', `#${container_id}`).off('click').on('click', evt => {\n $('.panorama', `#${container_id}`).hide()\n $('.panorama-bar', `#${container_id}`).hide()\n })\n // 设备列表相关\n $('.device-list h3', `#${container_id}`).off('cilck').on('click', evt => {\n $('.device-list', `#${container_id}`).hide()\n })\n $('.device-list ul', `#${container_id}`).off('click').on('click', 'li', evt => {\n const index = $(evt.currentTarget).data('index')\n device_index = index\n $('.device-list', `#${container_id}`).hide()\n drawInfomation()\n })\n $('.map-icon-list', `#${container_id}`).off('click').on('click', evt => {\n $('.device-list', `#${container_id}`).show()\n })\n }\n const setAndConvertMonitors = (data) => {\n monitors = data\n // GPS坐标转地图坐标,并写回原值\n convertor.translate(monitors.map(item => new BMap.Point(item.lng, item.lat)), 1, 5, data => {\n data.points.map((item, index) => Object.assign(monitors[index], item))\n drawInfomation()\n })\n }\n const drawInfomation = () => {\n const monitor = monitors[device_index]\n\n // 主界面移动到坐标\n const poi = new BMap.Point(monitor.lng, monitor.lat)\n marker && marker.setPosition(poi)\n map && map.panTo(poi, 19)\n\n const list = monitors.map((monitor, index) => `\n <li data-index=\"${index}\">\n <h4>${monitor.name}<span>(${monitor.location})</span> <span>${readableInfo(monitor)}</span></h4>\n <em>${monitor.address}</em>\n </li>\n `)\n $('.device-list ul', `#${container_id}`).empty().append(list)\n\n // 主界面相关信息\n $('.map-infomation h4', `#${container_id}`).html(`${monitor.name} <span>(${monitor.location})</span>`)\n $('.map-infomation em', `#${container_id}`).text(monitor.address)\n // device_info_new 3 离线\n // device_info_new 4 在线\n // gps_time 最后定位时间\n // heart_time 最后通讯时间\n let info = ''\n info += readableInfo(monitor)\n info += ' | 电源:'\n info += monitor.acc == '1' ? '开' : '关'\n info += `(${readableTime(monitor.acc_seconds)})`\n $('.map-infomation h5', `#${container_id}`).text(info)\n }\n try {\n // 加载外部依赖\n $.when($.ajax({\n url: 'https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js',\n cache: true,\n dataType: 'script'\n }), $.ajax({\n url: 'https://api.map.baidu.com/getscript?v=3.0&ak=EzLVbOoESbSGKG0DlhvUPPoSWOLPz4lk',\n cache: true,\n dataType: 'script'\n })).then(() => {\n // 兼容不支持await的浏览器\n\n // 初始化容器\n initContainer()\n // 初始化地图\n initMap()\n // 监听NR\n node.$watch('msg', function (msg) {\n if (msg.payload && msg.payload instanceof Array) {\n setAndConvertMonitors(msg.payload)\n }\n })\n })\n\n } catch (err) {\n alert(err.message)\n }\n }\n main(window.scope)\n </script>",
"storeOutMessages": true,
"fwdInMessages": true,
"templateScope": "local",
"x": 960,
"y": 410,
"wires": [
[]
]
},
{
"id": "187aa0fc.84398f",
"type": "ui_group",
"z": "",
"name": "V2坐标",
"tab": "ca215713.fc1fb8",
"order": 2,
"disp": true,
"width": "6",
"collapse": true
},
{
"id": "ca215713.fc1fb8",
"type": "ui_tab",
"z": "",
"name": "Home",
"icon": "dashboard",
"order": 1,
"disabled": false,
"hidden": false
}
]