方法概述
名称 | 返回值类值 | 描述 | 对象 |
---|---|---|---|
Promise<RouteSolveResult> | 使用路径参数求解针对路径图层的路径。 更多详情 | route |
方法详细说明
-
solve(url, params, requestOptions){Promise<RouteSolveResult>}
-
使用路径参数求解针对路径图层的路径。
参数url String表示网络分析服务的 GeoScene Server REST 资源的 URL。
params RouteParameters用作输入以生成路径的路径参数。
requestOptions Objectoptional用于数据请求的附加选项(将覆盖构造期间定义的 requestOptions)。
返回类型 描述 Promise<RouteSolveResult> 解析后,返回 RouteSolveResult 的实例。 示例require([ "geoscene/rest/route", "geoscene/core/Collection", "geoscene/rest/support/RouteParameters", "geoscene/rest/support/Stop", ... ], function(route, Collection, RouteParameters, Stop, ... ) { // point the URL to a valid routing service const routeUrl = "https://route-api.geoscene.cn/geoscene/rest/services/World/Route/NAServer/Route_World"; // create a Collection of new Stops const stops = new Collection([ new Stop({ geometry: { x: -117.59275, y: 34.06200 }, name: "Ontario Airport" }), new Stop({ geometry: { x: -117.19570, y: 34.05609 }, name: "Esri Campus" }) ]); // setup the RouteParameters with API key and Stops const routeParams = new RouteParameters({ // An authorization string used to access the routing service apiKey: "YOUR_API_KEY", stops }); // solve the route with the RouteParameters function solveRoute() { route.solve(routeUrl, routeParams).then(showRouteInfo); } // do something useful with the results // like display them to the console function showRouteInfo(routeSolveResult) { console.log("Show all results: ", routeSolveResult); console.log("Show the route information: ", routeSolveResult.routeResults[0].route); } solveRoute(); });