我项目中 用到了一个数据驱动点位的api,想要表达的是小区里面 几十个安保人员的具体位置, 但是接入方式需要用动态接口来快速更新点位位置信息和弹窗信息,webSocket和http的URL方式接入,选哪个方式比较合理呢?
const poi = new App.Poi({
"location": [121.37624691,31.15963937,37],
"poiStyle": {
"markerNormalUrl": "https://wdpapi.51aes.com/doc-static/images/static/markerNormal.png",
"markerActivateUrl": "https://wdpapi.51aes.com/doc-static/images/static/markerActive.png",
"markerSize": [50,114],
"labelBgImageUrl": "https://wdpapi.51aes.com/doc-static/images/static/LabelBg.png",
"labelBgSize": [115,22],
"labelBgOffset": [25,100], //x>0,y>0 向右、上偏移(x,y 单位:像素)
"labelContent": ["数据驱动移动","fcffb7ff","12"],
"labelTop": false,
"scrollSpeed": 5,
"textBoxWidth": 200,
"labelContentJustification": "Left",
"labelContentAutoWrap": true,
"scrollPolicy": "default"
},
"entityName": "myName1",
"customId": "my-poi-id",
"customData": {
"data": "myCustomData"
}
})
const res = await App.Scene.Add(poi);
const entityObj = [
{
objects: [poi],
location: [121.40110354,31.15382552,3],
time: 0 //实体移动到该位置所需时间
},
{
objects: [poi],
location: [121.3942475,31.14479155,98],
time: 5
},
{
objects: [poi],
location: [121.40488661,31.17504119,29],
time: 10
},
{
objects: [poi],
location: [121.38337962,31.17722974,65],
time: 5
},
{
objects: [poi],
location: [121.38337962,31.17722974,65],
time: 15
},
]
await App.Tools.MoveLinear.Move(entityObj,{
"calculateCoordZ": { //坐标类型及坐标高度; [可选] 最高优先级
"coordZRef": "surface",//Surface:表面;Ground:地面;Altitude:海拔
"coordZOffset": 50 //海拔 高度(单位:米)
}
});
这个是更新点位的具体API字段
频繁通讯,客户较少就用websocket.
通讯较少,访问量很大就用http.
用socket会一直占用服务器连接,所以会有数量限制.
综合考虑,分阶段单独实现或两者结合
几十个点位还好吧,你这个应该是大屏应用,客户一般不会开很多
实时更新这玩意还要看实际对讲机频率有多高,一般都是30s一次上报,太高了对讲机电量也撑不住
http就是10s调一次接口,拿所有人的定位
ws也不难,定位信息接进来后端广播就行