肯德基
']) */ @@ -2879,14 +2970,14 @@ MainMap_QM.prototype = { } }, /** - * @api {方法} unionShop() 店铺合并 + * @api {方法} unionShop() 店铺合并 * @apiGroup 地图显示 * @apiDescription 通过店铺编号合并店铺 合铺 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {Array} shops 店铺编号数组 * @apiParam {Object} data 新的店铺数据(默认 空数据) * @apiSampleRequest off - * + * * @apiParamExample {String} 请求示例 * Map_QM.unionShop(["L105","L106","L107","L108"],{name:"新店",shopNum:"L104-L108",color:"#F4A460"}) */ @@ -2997,12 +3088,12 @@ MainMap_QM.prototype = { let facCode = intersects[i].object.userData.facCode || intersects[i].object.parent.userData.facCode || intersects[i].object.parent.parent.userData.facCode let title = intersects[i].object.userData.title || intersects[i].object.parent.userData.title || intersects[i].object.parent.parent.userData.title /** - * @api {事件} icon 点击设施图标 + * @api {事件} icon 点击设施图标 * @apiGroup 地图事件 * @apiDescription 用户点击设施图标后触发自定义事件 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiSampleRequest off - * + * * @apiParamExample 请求示例 * Map_QM.addEventListener("icon",onClickIcon,false); */ @@ -3031,29 +3122,29 @@ MainMap_QM.prototype = { } } /** - * @api {事件} shop 点击已绑定品牌的店铺 + * @api {事件} shop 点击已绑定品牌的店铺 * @apiGroup 地图事件 * @apiDescription 用户点击店铺后触发自定义事件 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiSampleRequest off - * + * * @apiParamExample 请求示例 * Map_QM.addEventListener("shop",onClickShop,false); */ if (clickShop && Map_QM.selectShop && Map_QM.selectShop.userData) { - if ((iot && Map_QM.selectShop.userData.shopData.hasOwnProperty("shopName")) || (!iot && Map_QM.selectShop.userData.shopData.hasOwnProperty("name"))) { + if (Map_QM.selectShop.userData.shopData.hasOwnProperty("shopName")) { Map_QM.dispatchEvent({ type: "shop", data: Map_QM.selectShop.userData }) } else { /** - * @api {事件} onlyShop 点击未绑定品牌的店铺 + * @api {事件} onlyShop 点击未绑定品牌的店铺 * @apiGroup 地图事件 * @apiDescription 用户点击空店铺后触发自定义事件 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiSampleRequest off - * + * * @apiParamExample 请求示例 * Map_QM.addEventListener("onlyShop",onClickShop,false); */ @@ -3073,15 +3164,15 @@ MainMap_QM.prototype = { * @api {方法} setSelectShopMatByName(shopNum) 设置box 选中 * @apiGroup 地图交互 * @apiDescription 地图box 选中 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {String} shopNum POI编号 - * + * * @apiSampleRequest off - * + * * @apiParamExample {String} 请求示例 - * + * * Map_QM.setSelectShopMatByName("L101"); - * + * */ setSelectShopMatByName: function (ipName) { for (let i = 0; i < Map_QM.mapArr[Map_QM.util.selectBuild].length; i++) { @@ -3109,6 +3200,8 @@ MainMap_QM.prototype = { Map_QM.controls.update(); Map_QM.renderer.render(Map_QM.scene, Map_QM.camera); Map_QM.labelRenderer.render(Map_QM.scene, Map_QM.camera); + Map_QM.labelRenderer.renderObject( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj, Map_QM.camera ); + Map_QM.labelRenderer.zOrder( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj ); if (Map_QM.callBackLoadOver) { let floorData = []; for (let i = 0; i < Map_QM.util.allMap.length; i++) { @@ -3168,19 +3261,40 @@ MainMap_QM.prototype = { } } }, + disPlayEvent: function (e) { + clearTimeout(stateTime); + stateTime = setTimeout(() => { + clearTimeout(stateTime); + if (!Map_QM.util.pathStateObj.isPathState) { + let distance = Map_QM.controls.getDistance(); + if (distance <= Map_QM.util.changeDist.inner) { //切换到室内 + Map_QM.dispatchEvent({ + type: 'mapShowChange', + data: 'mall' + }) + } else { + Map_QM.dispatchEvent({ + type: 'mapShowChange', + data: 'out' + }) + } + } + }, 300); + }, /** * 碰撞检测 - * @param {Object} 传入检测楼层下标 + * @param {Object} 传入检测楼层下标 */ controlsChock: function () { Map_QM.autoChangeEleAngle(); + Map_QM.collLabel(); /** - * @api {事件} MapAngleChange 地图的方向改变 + * @api {事件} MapAngleChange 地图的方向改变 * @apiGroup 地图事件 * @apiDescription 用户操作地图时触发 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiSampleRequest off - * + * * @apiParamExample 请求示例 * Map_QM.addEventListener("MapAngleChange",onMapAngleChange,false); */ @@ -3271,7 +3385,6 @@ MainMap_QM.prototype = { Map_QM.hideObjecrGap(Map_QM.outModelGap, true); } } - Map_QM.collLabel(); }, hideObjecrGap: function (gap, isShow) { @@ -3289,12 +3402,17 @@ MainMap_QM.prototype = { //内部碰撞检测 collLabel: function () { - if (!Map_QM || !Map_QM.util.options.collision) { + if (!Map_QM) { return; } - + clearTimeout(Map_QM.util.timeObj.collTime); Map_QM.util.timeObj.collTime = setTimeout(() => { clearTimeout(Map_QM.util.timeObj.collTime); + Map_QM.labelRenderer.zOrder( Map_QM.mapArr[Map_QM.util.selectBuild][Map_QM.util.selectFloor].labelObj ); + if (!Map_QM.util.options.collision) { + return; + } + let checkList = []; if (Map_QM.util.options.overlap) { for (let i = 0; i < Map_QM.mapArr[Map_QM.util.selectBuild].length; i++) { @@ -3305,36 +3423,30 @@ MainMap_QM.prototype = { }); } } - if (Map_QM.mapArr[Map_QM.util.selectBuild]) { + if (Map_QM.mapArr[Map_QM.util.selectBuild] && Map_QM.buildObj.visible) { for (let m = 0; m < Map_QM.mapArr[Map_QM.util.selectBuild].length; m++) { if (Map_QM.mapArr[Map_QM.util.selectBuild][m].allObj.visible && (!Map_QM.buildObj.userData.hasOwnProperty("visible") || Map_QM.buildObj.userData.visible)) { let childs = Map_QM.mapArr[Map_QM.util.selectBuild][m].labelObj.children; let len = childs.length; for (let i = 0; i < len; i++) { let obj = childs[i].element - if(childs[i].userData.mapShow){ + if (childs[i].userData.mapShow) { obj.style.visibility = "visible"; - }else{ + } else { obj.style.visibility = "hidden"; } if (obj.style.transform) { obj.style.visibility = "visible" - let labP = obj.style.transform.split('translate')[2].split(', ') + let labP = obj.getBoundingClientRect(); for (let j = 0; j < i; j++) { if (childs[j].element.style.visibility == "visible") { - let pb = childs[j].element.style.transform.split('translate')[2].split(', ') - let isCol = Map_QM.util.isCollision( - new Map_QM.util.Point(labP[0].substring(1, labP[0].length - 2), labP[1].substring(0, labP[1].length - 3)), - obj.clientWidth, - obj.clientHeight, - new Map_QM.util.Point(pb[0].substring(1, pb[0].length - 2), pb[1].substring(0, pb[1].length - 3)), - childs[j].element.clientWidth, - childs[j].element.clientHeight - ) + let pb = childs[j].element.getBoundingClientRect(); + let isCol = Map_QM.util.isCollision(labP, pb); if (isCol) { - if(!childs[i].userData.mapShow){ + if (!childs[i].userData.mapShow) { obj.style.visibility = "hidden" - }else if(!childs[j].userData.mapShow){ + break; + } else if (!childs[j].userData.mapShow) { childs[j].element.style.visibility = "hidden" } } @@ -3382,15 +3494,15 @@ MainMap_QM.prototype = { * @api {方法} bounceIcon({type:"xsj"}) 图标弹跳 * @apiGroup 地图导航 * @apiDescription 地图图标弹跳效果 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {String} iconType 设施缩写 - * + * * @apiSampleRequest off - * + * * @apiParamExample {String} 请求示例 - * + * * Map_QM.bounceIcon({type:"xsj"}); - * + * */ bounceIcon: function (iconType) { let toFloor = parseInt(Map_QM.util.selectFloor); @@ -3404,29 +3516,366 @@ MainMap_QM.prototype = { } } }, + /** + * @api {方法} countPath() 方向算法 + * @apiGroup 地图导航 + * @apiDescription 计算设施、店铺的导航方向, toObj,pathType 不能同时为空 + * @apiVersion 4.0.0 + * @param {Object} toObj {build,floor,node} //终点 设施寻路可以为空 + * @param {String} pathType 公共设施名称或编号(点位寻路此参数为空字符串) + * @param {String} countType 8--八方向(默认) 12--十二方向 + * + * @apiSampleRequest off + * + * @apiParamExample {String} 请求示例 + * + * Map_QM.countPath({build:0,floor:0,node:0},"xsj","8"); + * + */ + countPath: function (toObj, pathType = "", _countType = "8") { + direction = { "code": 500, "dir": '', "cost": 0, "gap": 0 }; + countType = _countType; + Map_QM.util.overObj = null; + if (pathType == "") { //传入终点导航点 + Map_QM.util.overObj = toObj; + if (Map_QM.util.startObj.node != "" && Map_QM.util.startObj.node != "-1" && Map_QM.util.overObj.node != "") { + this.forShopArr.length = 0; + return this.forDirPath(); + } else { + direction.code = "404"; + return direction + } + } else { // + let iconPath = this.pathIcon({ type: pathType }); + Map_QM.util.overObj = iconPath; + if (Map_QM.util.startObj.node != "" && Map_QM.util.startObj.node != "-1" && Map_QM.util.overObj.node != "") { + this.forShopArr.length = 0; + return this.forDirPath(); + } + } + return direction = { "code": 404, "dir": '', "cost": 0, "gap": 0 }; + }, + forDirPath: function () { + let startNade = Map_QM.util.startObj.build + "_" + Map_QM.util.startObj.floor + "_" + Map_QM.util.startObj.node; + let toNade = Map_QM.util.overObj.build + "_" + Map_QM.util.overObj.floor + "_" + Map_QM.util.overObj.node; + let PathPoint; + direction = { "code": 500, "dir": '', "cost": 0, "gap": 0 }; + try { + let obj = dijkstra.find_path(Map_QM.util.pathStateObj.graphPath, startNade, toNade); + PathPoint = obj.nodes; + direction.cost = Math.floor(obj.cost / Map_QM.util.options.mapScale * 0.9); + direction.gap = parseInt(obj.cost / Map_QM.util.options.mapScale); + } catch (e) { + console.log(e); + direction.code = 404; + return direction; + } + let index = 0; + this.forShopArr = []; + if (PathPoint.length > 1) { + this.forShopArr.push({ build: Map_QM.util.startObj.build, floor: Map_QM.util.startObj.floor, PathPoint: [] }); + let pathData; + for (let j = 0; j < PathPoint.length; j++) { + let array = PathPoint[j].split("_"); + pathData = Map_QM.util.allMap[parseInt(array[0])].buildArr[parseInt(array[1])].mapData.path; + pathData.nodes.sort(Map_QM.util.sortNumber); + if (parseInt(array[1]) == this.forShopArr[index].floor) { //同层 + this.forShopArr[index].PathPoint.push(pathData.nodes[parseInt(array[2])]); + } else { + this.forShopArr.push({ build: parseInt(array[0]), floor: parseInt(array[1]), PathPoint: [] }); + index++; + this.forShopArr[index].PathPoint.push(pathData.nodes[parseInt(array[2])]); + } + } + } else { + this.forShopArr.length = 0; + } + if (this.forShopArr.length > 0) { //--------------------------计算方向 + direction.code = 200; + if (countType == "12") { //16方向 + Map_QM.countSixteenArrow(); + } else { + Map_QM.countStartAndEndDire(); + } + + } + console.log(this.forShopArr) + if (this.forShopArr.length > 1) { + let facType; + if (this.forShopArr[0].floor > this.forShopArr[1].floor) { //下 + if (Math.abs(parseInt(this.forShopArr[0].floor) - parseInt(this.forShopArr[1].floor)) < 3) { //扶梯 + facType = Map_QM.util.getFacType("downft"); + } else { + facType = Map_QM.util.getFacType("dt"); + } + } else { + if (Math.abs(parseInt(this.forShopArr[0].floor) - parseInt(this.forShopArr[1].floor)) < 3) { //扶梯 + facType = Map_QM.util.getFacType("upft"); + } else { + facType = Map_QM.util.getFacType("dt"); + } + } + facType = facType + ""; + if (facType.length === 1) { + direction.dir = "600" + facType; + } else if (facType.length === 2) { + direction.dir = "60" + facType; + } else if (facType.length === 3) { + direction.dir = "6" + facType; + } + } + return direction; + }, + /** + * 计算十六方向箭头 + */ + countSixteenArrow: function () { + if (this.forShopArr[0].PathPoint.length > 1) { + let keyPoints = [], ishas = false, allCount = 0; + for (let i = 1; i < this.forShopArr[0].PathPoint.length; i++) { + let s = Math.sqrt(Math.pow((this.forShopArr[0].PathPoint[i].x - this.forShopArr[0].PathPoint[i - 1].x), 2) + Math.pow((this.forShopArr[0].PathPoint[i].y - this.forShopArr[0].PathPoint[i - 1].y), 2)); + if (s < 20) { + continue; + } + ishas = false; + let dirObj = { angleName: Map_QM.getPathAngle(this.forShopArr[0].PathPoint[i - 1], this.forShopArr[0].PathPoint[i]), count: s }; + allCount += s; + if (keyPoints.length > 0 && keyPoints[keyPoints.length - 1].angleName == dirObj.angleName) { + keyPoints[keyPoints.length - 1].count += s; + ishas = true; + } + if (!ishas) { + keyPoints.push(dirObj); + } + } + if (allCount < 150) { //总长度< 150 按8方向 + Map_QM.countStartAndEndDire(); + return; + } + if (keyPoints.length == 1) { + direction.dir = Map_QM.getDirByName(keyPoints[0].angleName); + return; + } + if (keyPoints.length == 0) { //没有路径,按方向计算 + direction.code = 404; + return; + } + let upCount = 0, rightFrontCount = 0, rightCount = 0, leftFrontCount = 0; + for (let item of keyPoints) { + if (item.angleName == "up") { + upCount += item.count; + } else if (item.angleName == "down") { + upCount -= item.count; + } else if (item.angleName == "right") { + rightCount += item.count; + } else if (item.angleName == "left") { + rightCount -= item.count; + } else if (item.angleName == "rightFront") { + rightFrontCount += item.count; + } else if (item.angleName == "rightRear") { + leftFrontCount -= item.count; + } else if (item.angleName == "leftFront") { + leftFrontCount += item.count; + } else if (item.angleName == "leftRear") { + rightFrontCount -= item.count; + } + } + console.log(keyPoints) + //斜方向忽略 + let dir1 = ""; + let bjCount = Math.max(150, allCount / 10); + let onlyDir = ""; + for (let item of keyPoints) { + if (item.angleName != "rightFront" && item.angleName != "leftFront" && item.angleName != "rightRear" && item.angleName != "leftRear") { + onlyDir = dir1.length > 0 ? dir1.substring(dir1.length - 1, dir1.length) : dir1; + if (item.angleName == "down" && (item.count > bjCount || upCount < -1 * bjCount)) { + if (onlyDir != "D") { + dir1 += "D"; + } + } else if (item.angleName == "up" && (item.count > bjCount || upCount > bjCount)) { + if (onlyDir != "T") { + dir1 += "T"; + } + } else if (item.angleName == "right" && (item.count > bjCount || rightCount > bjCount)) { + if (onlyDir != "R") { + dir1 += "R"; + } + } else if (item.angleName == "left" && (item.count > bjCount || rightCount < -1 * bjCount)) { + if (onlyDir != "L") { + dir1 += "L"; + } + } + } + } + //console.log(dir1) + if (dir1.length > 2) dir1 = dir1.substring(0, 2) //两个以上方向 + direction.dir = Map_QM.getDirByName(dir1); + if (!direction.dir) Map_QM.countStartAndEndDire(); + + } else { //没有路径,按方向计算 + direction.code = 404; + } + }, + + getDirByName: function (dir) { + switch (dir) { + default: + return ""; + case "T": + return "1201"; + case "R": + return "1202"; + case "D": + return "1203"; + case "L": + return "1204"; + case "TL": + return "1205"; + case "TR": + return "1206"; + case "RT": + return "1207"; + case "RD": + return "1208"; + case "DL": + return "1209"; + case "DR": + return "1210"; + case "LT": + return "1211"; + case "LD": + return "1212"; + case "up": + return "1201"; + case "rightFront": + return "8002"; + case "right": + return "1202"; + case "rightRear": + return "8004"; + case "down": + return "1203"; + case "leftRear": + return "8006"; + case "left": + return "1204"; + case "leftFront": + return "8008"; + } + }, + + /** + * 计算八方向坐标 + */ + countStartAndEndDire: function () { + let sPoint = new Map_QM.util.Point(this.forShopArr[0].PathPoint[0].x, this.forShopArr[0].PathPoint[0].y); //本层起始点坐标 + let ePoint = new Map_QM.util.Point(this.forShopArr[0].PathPoint[this.forShopArr[0].PathPoint.length - 1].x, this.forShopArr[0].PathPoint[this.forShopArr[0].PathPoint.length - 1].y); //本层结束点坐标 + switch (Map_QM.getPathAngle(sPoint, ePoint)) { + default: + direction.dir = "8001"; + case "up": + direction.dir = "8001"; + break; + case "rightFront": + direction.dir = "8002"; + break; + case "right": + direction.dir = "8003"; + break; + case "rightRear": + direction.dir = "8004"; + break; + case "down": + direction.dir = "8005"; + break; + case "leftRear": + direction.dir = "8006"; + break; + case "left": + direction.dir = "8007"; + break; + case "leftFront": + direction.dir = "8008"; + break; + } + }, + + getPathAngle: function (sPoint, ePoint) { + let x = Math.abs(sPoint.x - ePoint.x); + let y = Math.abs(sPoint.y - ePoint.y); + let tan = x / y; + let radina = Math.atan(tan);//用反三角函数求弧度 + let angle = Math.floor(180 / (Math.PI / radina)) || 0;//将弧度转换成角度 + + if (ePoint.x > sPoint.x && ePoint.y > sPoint.y) {// 右下方 + angle = 180 - angle; + } + if (ePoint.x == sPoint.x && ePoint.y > sPoint.y) {// 正下方 + angle = 180; + } + if (ePoint.x < sPoint.x && ePoint.y > sPoint.y) {//左下方 + angle = angle - 180; + } + if (ePoint.x < sPoint.x && ePoint.y == sPoint.y) {//左方 + angle = -90; + } + if (ePoint.x < sPoint.x && ePoint.y < sPoint.y) {// 左上方 + angle = (-1) * angle; + } + if (ePoint.x == sPoint.x && ePoint.y < sPoint.y) {//上方 + angle = 0; + } + if (ePoint.x > sPoint.x && ePoint.y < sPoint.y) {//右上方 + angle = angle; + } + if (ePoint.x > sPoint.x && ePoint.y == sPoint.y) {//point在x轴正方向上 + angle = 90; + } + angle -= Map_QM.util.deviceObj.angle; + angle = angle > 180 ? angle - 360 : angle; + angle = angle < -180 ? angle + 360 : angle; + + if (angle > -22 && angle <= 22) { //前 + return "up"; + } else if (angle > 22 && angle <= 67) { //右前 + return "rightFront"; + } else if (angle > 67 && angle <= 112) { //右 + return "right"; + } else if (angle > 112 && angle <= 158) { //右后 + return "rightRear"; + } else if (angle > 158 || angle <= -158) { //后 + return "down"; + } else if (angle > -158 && angle <= -112) { //左后 + return "leftRear"; + } else if (angle > -112 && angle <= -67) { //左 + return "left"; + } else { //左前 + return "leftFront"; + } + + }, /** * @api {方法} pathIcon({type:"xsj"}) 获取最近设施 * @apiGroup 地图导航 * @apiDescription 获取离当前楼层最近的设施 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {JSON} type 设施缩写 - * + * * @apiSampleRequest off - * - * @apiParamExample {String} 请求示例 - * + * + * @apiParamExample {String} 请求示例 + * * Map_QM.pathIcon({type:"xsj"}); - * + * * @apiSuccessExample 返回示例 * { * "floor": 楼层编号, "node": 设施导航点,"typeCode":设施编号 * } - * + * */ pathIcon: function (iconType) { let selIcon; // let minS = -1; - toIcon = iconType.type; if (!Map_QM.util.startObj.build && parseInt(Map_QM.util.startObj.build) != 0) { Map_QM.util.startObj.build = parseInt(Map_QM.util.deviceObj.build); } @@ -3455,7 +3904,7 @@ MainMap_QM.prototype = { } if (selIcon) { - return { "build": parseInt(Map_QM.util.deviceObj.build), "floor": selIcon.floor, site: { x: selIcon.position.x, y: selIcon.position.y }, "node": selIcon.navCode, "no": selIcon.no, "typeCode": Map_QM.util.getFacType(iconType.type) }; + return { "build": parseInt(Map_QM.util.deviceObj.build), "floor": selIcon.floor, "site": { x: selIcon.position.x, y: selIcon.position.y }, "node": selIcon.navCode, "no": selIcon.no, "typeCode": Map_QM.util.getFacType(iconType.type) }; } else { // 当前楼栋没有 for (let b = 0; b < Map_QM.mapArr.length; b++) { if (b != parseInt(Map_QM.util.deviceObj.build)) { @@ -3463,17 +3912,19 @@ MainMap_QM.prototype = { let sers = Map_QM.mapArr[b][i].serObj.children; //服务图标 for (let n = 0; n < sers.length; n++) { if (sers[n].facCode == iconType.type) { - let toNade = parseInt(Map_QM.util.deviceObj.build) + "_" + sers[n].floor + "_" + sers[n].navCode; + let toNade = b + "_" + sers[n].floor + "_" + sers[n].navCode; if (!selIcon) { minS = costAll[toNade]; if (minS) { selIcon = sers[n]; + selIcon.build = b; } } else { let s1 = costAll[toNade]; if (s1 && s1 < minS) { minS = s1; selIcon = sers[n]; + selIcon.build = b; } } } @@ -3481,9 +3932,9 @@ MainMap_QM.prototype = { } } } - } - if (selIcon) { - return { "build": parseInt(Map_QM.util.deviceObj.build), "floor": selIcon.floor, "node": selIcon.navCode, site: { x: selIcon.position.x, y: selIcon.position.y }, "no": selIcon.no, "typeCode": Map_QM.util.getFacType(iconType.type) }; + if (selIcon) { + return { "build": selIcon.build, "floor": selIcon.floor, "node": selIcon.navCode, "site": { x: selIcon.position.x, y: selIcon.position.y }, "no": selIcon.no, "typeCode": Map_QM.util.getFacType(iconType.type) }; + } } } }, @@ -3491,21 +3942,21 @@ MainMap_QM.prototype = { * @api {方法} pathByStartAndOver(startObj,toObj,callBackFun) 地图路径规划 * @apiGroup 地图导航 * @apiDescription 根据传入的起、终点;直接导航 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {String} startObj.shopNum 店铺编号/车位编号 * @apiParam {String} startObj.type "shop"/"park" - * + * * @apiParam {String} toObj.shopNum 店铺编号/车位编号 * @apiParam {String} toObj.type "shop"/"park" - * + * * @apiParam {Function} callBackFun 回调函数 - * + * * @apiSampleRequest off - * + * * @apiParamExample {String} 请求示例 - * + * * Map_QM.pathByStartAndOver({"shopNum":"L102","type":"shop"},{"shopNum":"L204","type":"shop"}); - * + * */ pathByStartAndOver: function (startObj, toObj, callBackFun) { try { @@ -3521,18 +3972,18 @@ MainMap_QM.prototype = { * @api {方法} changeStartPoint() 设置起始点位 * @apiGroup 地图导航 * @apiDescription 设置起始点位 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {int} build 起点楼栋编号 * @apiParam {int} floor 起点楼层编号 * @apiParam {String} node 起点编号 * @apiParam {int} angle 起点角度 - * + * * @apiSampleRequest off - * + * * @apiParamExample {String} 请求示例 - * + * * Map_QM.changeStartPoint({"build":0, "floor":3, "node":"20", "angle":0}); - * + * */ changeStartPoint: function (toObj) { this.clearFloor(); @@ -3570,16 +4021,16 @@ MainMap_QM.prototype = { * @api {方法} changeMapIPState(ipName,color) 改变POI颜色 * @apiGroup 地图交互 * @apiDescription 改变POI 颜色 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {string} ipName POI名称 - * @apiParam {string} color 颜色字符串 - * + * @apiParam {string} color 颜色字符串 + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.changeMapIPState("L1001","#ffff00"); - * + * */ changeMapIPState: function (ipName, color) { // #775544 #AD8164 for (let i = 0; i < this.mapArr[this.util.selectBuild].length; i++) { @@ -3593,18 +4044,18 @@ MainMap_QM.prototype = { } }, /** - * @api {方法} getMapIPData(ipName) 获取POI 基础数据 + * @api {方法} getMapIPData(ipName) 获取POI 基础数据 * @apiGroup 地图交互 * @apiDescription 获取POI 基础数据 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {string} ipName POI名称 - * + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.getMapIPData("L1001"); - * + * * @apiSuccessExample 返回示例 * { * shopNum:店铺编号, shopName:店铺名 node:导航点, floor:楼层编号, xaxis:中心点X坐标, yaxis:中心点Y坐标, borderColor:边框色, entColor:填充色 @@ -3625,17 +4076,17 @@ MainMap_QM.prototype = { * @api {方法} pathNode() 地图模拟导航 * @apiGroup 地图导航 * @apiDescription 地图路径模拟导航 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {int} floor 楼层编号 * @apiParam {string} node 路径点位编号 * @apiParam {function} callBackFun 回调方法 - * + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.pathNode({build:0, floor:2,node:"53"},callBackFun); - * + * */ pathNode: function (toObj, callBackFun) { if (!toObj) { @@ -3654,7 +4105,7 @@ MainMap_QM.prototype = { Map_QM.changeStartPoint(null); } Map_QM.util.overObj = null; - Map_QM.util.overObj = { build: toObj.build || 0, floor: toObj.floor, node: toObj.node, shopNum: toObj.shopNum,comeIn: toObj.comeIn || "" }; + Map_QM.util.overObj = { build: toObj.build || 0, floor: toObj.floor, node: toObj.node, shopNum: toObj.shopNum, comeIn: toObj.comeIn || "" }; if (Map_QM.util.overObj.node != "") { Map_QM.cancelRender(); this.onFindPathModel(); @@ -3680,14 +4131,14 @@ MainMap_QM.prototype = { } if (item.hasOwnProperty("wayShop") && item.wayShop) { for (let i = 0; i < item.wayShop.length; i++) { - let enTlite = item.wayShop[i].shop.nameEn == "" ? item.wayShop[i].shop.name : item.wayShop[i].shop.nameEn; - Map_QM.util.pathStateObj.forShopArr.wayList.push({ isAddPrefix: false, name: "经过 " + item.wayShop[i].shop.name, nameEn: "PASS " + enTlite, logoPath: item.wayShop[i].shop.logoPath, code: item.wayShop[i].shop.code, shopNum: iot ? item.wayShop[i].shop.houseNumber : item.wayShop[i].shop.houseNum }); + let enTlite = item.wayShop[i].shop.shopNameEn == "" ? item.wayShop[i].shop.shopName : item.wayShop[i].shop.shopNameEn; + Map_QM.util.pathStateObj.forShopArr.wayList.push({ isAddPrefix: false, shopName: "经过 " + item.wayShop[i].shop.shopName || item.wayShop[i].shop.name, shopNameEn: "PASS " + enTlite, logoPath: item.wayShop[i].shop.logoPath, code: item.wayShop[i].shop.code, shopNum: iot ? item.wayShop[i].shop.houseNumber : item.wayShop[i].shop.houseNum }); } } if (item.hasOwnProperty("Facilities") && item.Facilities) { //设施 Map_QM.util.pathStateObj.forShopArr.wayList.push({ - isAddPrefix: true, name: "乘坐 " + item.Facilities.userData.title + "到 " + Map_QM.mapArr[Map_QM.util.selectBuild][parseInt(Map_QM.forShopArr[index + 1].floor)].floorName, - nameEn: "BY " + item.Facilities.userData.title + "TO " + Map_QM.mapArr[Map_QM.util.selectBuild][parseInt(Map_QM.forShopArr[index + 1].floor)].floorName, logoPath: item.Facilities.imgUrl, code: (((Math.random()) * 0x1234567) | 0).toString(16).substring(0), shopNum: item.Facilities.userData.facCode + item.Facilities.userData.no + isAddPrefix: true, shopName: "乘坐 " + item.Facilities.userData.title + "到 " + Map_QM.mapArr[Map_QM.util.selectBuild][parseInt(Map_QM.forShopArr[index + 1].floor)].floorName, + shopNameEn: "BY " + item.Facilities.userData.title + "TO " + Map_QM.mapArr[Map_QM.util.selectBuild][parseInt(Map_QM.forShopArr[index + 1].floor)].floorName, logoPath: item.Facilities.imgUrl, code: (((Math.random()) * 0x1234567) | 0).toString(16).substring(0), shopNum: item.Facilities.userData.facCode + item.Facilities.userData.no }); } }); @@ -3696,16 +4147,16 @@ MainMap_QM.prototype = { * @api {方法} getGapByPathNode() 获取实际距离 * @apiGroup 地图导航 * @apiDescription 通过点位获取距离 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {int} floor 楼层编号 * @apiParam {string} node 路径点位编号 - * + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.getGapByPathNode({floor:2,node:"53"}); - * + * * @apiSuccessExample {Object} dist 距离米数 time 步行时间 * { * dis:200,time:4 @@ -3718,7 +4169,7 @@ MainMap_QM.prototype = { try { path = dijkstra.find_path(Map_QM.util.pathStateObj.graphPath, startNade, toNade); minTime = parseInt(path.cost / Map_QM.util.options.mapScale / 50) < 0.5 ? 0.5 : parseInt(path.cost / Map_QM.util.options.mapScale / 50); - console.log(`距离目的地 ${parseInt(path.cost / Map_QM.util.options.mapScale)} 米,预计${mint} 分钟`); // 21 是比例尺 + console.log(`距离目的地 ${parseInt(path.cost / Map_QM.util.options.mapScale)} 米,预计${minTime} 分钟`); // 21 是比例尺 } catch (e) { console.log(e) } @@ -3728,11 +4179,11 @@ MainMap_QM.prototype = { * @api {方法} getAllIcon() 获取所有Icon * @apiGroup 地图数据 * @apiDescription 获取所有Icon - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {int} floorOrder 楼层编号(默认 所有) - * + * * @apiSampleRequest off - * + * */ getAllIcon: function (floorOrder = -1, buildOrder = -1) { let icons = []; @@ -3790,15 +4241,15 @@ MainMap_QM.prototype = { * @api {方法} pathPark() 获取车位点位 * @apiGroup 地图数据 * @apiDescription 获取车位导航点 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {String} shopNum 车位编号 - * + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.pathPark({shopNum:"B1002"}); - * + * * @apiSuccessExample 返回示例 * { * shopNum: 车位编号, node: 导航点, floor: 楼层编号, xaxis: 中心点X坐标, yaxis: 中心点Y坐标 @@ -3812,15 +4263,15 @@ MainMap_QM.prototype = { * @api {方法} pathShopByName() 获取店铺点位 * @apiGroup 地图数据 * @apiDescription 通过店铺名称获取点位 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiParam {String} shopName 店铺名称 - * + * * @apiSampleRequest off - * + * * @apiParamExample 请求示例 - * + * * Map_QM.pathShopByName("金拱门"); - * + * * @apiSuccessExample 返回示例 * { * shopNum: 店铺编号, node: 导航点, floor: 楼层编号, xaxis: 中心点X坐标, yaxis: 中心点Y坐标, comeIn:店铺多门点 @@ -3857,12 +4308,12 @@ MainMap_QM.prototype = { * @api {方法} shopNumToNavPoint() 获取导航点位 * @apiGroup 地图导航 * @apiDescription 通过店铺编号或车位获取导航点位 - * @apiVersion 2.0.0 - * @apiParam {Object} object build,floor,shopNum 楼栋编号,楼层编号,店铺或车位编号 + * @apiVersion 4.0.0 + * @apiParam {Object} object build,floor,shopNum 楼栋编号,楼层编号,店铺或车位编号 * @apiParam {String} type 店铺或车位标识 "shop" "park" - * + * * @apiSampleRequest off - * + * * @apiSuccessExample 返回示例 * { * shopNum: 店铺编号, node: 导航点, floor: 楼层编号, xaxis: 中心点X坐标, yaxis: 中心点Y坐标, comeIn:店铺多门点 @@ -3915,11 +4366,11 @@ MainMap_QM.prototype = { if (!usePath) { usePath = Map_QM.util.pathStateObj.graphPath; } - if(Map_QM.util.overObj.comeIn){ + if (Map_QM.util.overObj.comeIn) { const costall = dijkstra.single_source_shortest_paths(Map_QM.util.pathStateObj.graphPath, startNade, startNade).costs; - if(costall){ + if (costall) { let inArray = Map_QM.util.overObj.comeIn.split(","); - Map_QM.util.overObj.node = Map_QM.getMinCostByArray(Map_QM.util.overObj.floor,inArray, costall); + Map_QM.util.overObj.node = Map_QM.getMinCostByArray(Map_QM.util.overObj.floor, inArray, costall); } } Map_QM.forShopPath(usePath); @@ -4014,9 +4465,9 @@ MainMap_QM.prototype = { * @api {事件} InitPathOver 地图导航状态完成 * @apiGroup 地图事件 * @apiDescription 地图开始导航时触发 - * @apiVersion 2.0.0 + * @apiVersion 4.0.0 * @apiSampleRequest off - * + * * @apiParamExample 请求示例 * Map_QM.addEventListener("InitPathOver",onInitPathOver,false); */ @@ -4031,22 +4482,22 @@ MainMap_QM.prototype = { this.onFindPathToObj(); } }, - getMinCostByArray:function(floor,array,costall){ - if(!Map_QM.util.startObj){ + getMinCostByArray: function (floor, array, costall) { + if (!Map_QM.util.startObj) { Map_QM.changeStartPoint(); } - if(!Map_QM.util.numBuild){ + if (!Map_QM.util.numBuild) { Map_QM.util.numBuild = 0; } - let mis=-1,nodeP; - for(let i=0; iGUI\'s constructor:\n\n \n\n localStorage on exit.\n\n localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n GUI\'s constructor:\n\n \n\n localStorage on exit.\n\n localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n