MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / findShortestPath

Method findShortestPath

src/maplibregl/overlay/GraphMap.js:99–112  ·  view source on GitHub ↗

* @function GraphMap.prototype.findShortestPath * @version 11.2.0 * @description 获取开始节点和结束节点之间的最短路径。(在渲染完成后调用) * @param {GraphMap.findShortestPathParams} params - 参数。 * @param {RequestCallback} [callback] - 回调函数,该参数未传时可通过返回的 promise 获取结果。 * @returns {Promise} Promise 对象。

(params, callback)

Source from the content-addressed store, hash-verified

97 * @returns {Promise} Promise 对象。
98 */
99 findShortestPath(params, callback) {
100 const { startID, endID, isHighlight = true, highlightStateStyles = {} } = params;
101 return this.knowledgeGraphService.findShortestPath({ startID, endID }, (res) => {
102 callback && callback(res);
103 if (isHighlight) {
104 if (res.type === 'processCompleted' && res.result.succeed) {
105 const { nodeIDs, edgeIDs } = res.result;
106 this.highlight({ nodeIDs, edgeIDs, ...highlightStateStyles });
107 } else {
108 alert(res.error.errorMsg, false);
109 }
110 }
111 });
112 }
113
114 /**
115 * @function GraphMap.prototype.highlight

Callers

nothing calls this directly

Calls 2

highlightMethod · 0.95
callbackFunction · 0.50

Tested by

no test coverage detected