首页 / 浏览问题 / WebGIS / 问题详情
iClient-leaflet开发最佳路径分析400请求错误
5EXP 2024年03月14日

产品:iServer 11.1.1

在iServer上发布地图和交通分析服务后。编写最佳路径分析方法的代码,执行后出错,console.log提示错误信息:"执行 findPath 操作时出错,原因是:findPath\n对象已经被释放 "

var mymap;
var urlMY="http://192.168.74.16:8090/iserver/services/map-Malaysia_retail/rest/maps/Country_R%40malaysia_source";
    urlMYNight="http://192.168.74.16:8090/iserver/services/map-Malaysia_retail/rest/maps/Country_R%40malaysia_source1";
    urlservice ="http://192.168.74.16:8090/iserver/services/transportationAnalyst-Malaysia_retail/rest/networkanalyst/RoadNet@Kuala_Lumpur_source";
  
var supermarketPoints = [];
var resultLayer;
var findPathService, findPathParameters;
var trackLocationLayer = [];
var geoLocationID;

function loadLeafletMap(){
    var MY = new L.supermap.tiledMapLayer(urlMY,{noWrap:true});
    var MYNight = new L.supermap.tiledMapLayer(urlMYNight,{noWrap:true});
    mymap = L.map('mapid', {
        layers: MY,
        crs: L.CRS.EPSG3857
    }).setView([3.140300, 101.688015],12);
    var baseMaps = {"Malaysia": MY, "MalaysiaDark": MYNight};
    L.control.layers(baseMaps).addTo(mymap);
}

function querySupermarket(){
    console.log("start querying");
    var param = new L.supermap.QueryBySQLParameters({
        queryParams: new L.supermap.FilterParameter({
            name: "pois@Kuala_Lumpur_source",
            attributeFilter: "fclass = 'supermarket'"
        })
    });
    // console.log("param:");
    // console.log(param);
    L.supermap.queryService(urlMY).queryBySQL(param, function(serviceResult){
        // console.log("result1:");
        // console.log(serviceResult.result);
        var result = serviceResult.result;

        var supermarketIcon = L.icon({
            iconUrl:'images/supermarketIcon.png',
            iconSize:[30]
        });

        resultLayer = L.featureGroup().addTo(mymap);
        // console.log(resultLayer);
        for(var i = 0; i < result.recordsets[0].features.features.length; i++){
            var p = result.recordsets[0].features.features[i];
            var latlng = L.point(p.geometry.coordinates[0],p.geometry.coordinates[1]);
            supermarketPoints.push(latlng);
            var marker1 = L.marker(L.CRS.EPSG3857.unproject(latlng), {icon:supermarketIcon})
                .bindPopup('Supermarket Name: ' + p.properties.name)
            resultLayer.addLayer(marker1);
        };
        
        console.log("loaded complete");
    })
}

function SupermarketPath(){
    // 获取网络分析的地址
    findPathService = new L.supermap.NetworkAnalystService(urlservice);
    // 创建最佳路径分析参数实例
    var resultSetting = new L.supermap.TransportationAnalystResultSetting({
        returnEdgeFeatures: true,
        returnEdgeGeometry: true,
        returnEdgeIDs: true,
        returnNodeFeatures: true,
        returnNodeGeometry: true,
        returnNodeIDs: true,
        returnPathGuides: true,
        returnRoutes: true
    });
    console.log('supermarketPoints');
    console.log(supermarketPoints);

    var analystParameter = new L.supermap.TransportationAnalystParameter({
        resultSetting: resultSetting, //分析结果返回显示内容
        weightFieldName: "SmLength" //阻力字段
    });
    findPathParameters = new L.supermap.FindPathParameters({
        isAnalyzeById: false,
        nodes: [supermarketPoints[0], supermarketPoints[1]],
        parameter: analystParameter
    });
    var myIcon = L.icon({
        iconUrl: "images/walk.png",
        iconSize: [20,20]
    });
    //进行路径查找
    findPathService.findPath(findPathParameters, function (serviceResult){
        var result = serviceResult.result;
        console.log('findPathService result:');
        console.log(serviceResult);
        result.pathList.map(function (result){
            L.geoJSON(result.route).addTo(mymap);
            L.geoJSON(result.pathGuideItems,{
                pointToLayer: function (geoPoints, latlng) {
                    L.marker(latlng, {icon: myIcon}).addTo(mymap);
                },filter:function (geoJsonFeature){
                    if(geoJsonFeature.geometry && geoJsonFeature.geometry.type === 'Point'){
                        return true;
                    }
                    return false;
                }
            }).addTo(mymap);
        })
    });
    console.log('findPathService');
    console.log(findPathService);
}

请问该错误是什么原因?该如何查找错误?

1个回答

你好,请检查以下步骤来排查问题:

1、发布的网络数据集在桌面进行路径分析时是否成功?是否开启了ssc分析模型?

2、在iserver界面进行最佳路径分析是否能成功返回结果?

3、发布服务流程是否正确?参考博客的发布流程:https://blog.csdn.net/supermapsupport/article/details/131681536

希望能够帮助到您!

765EXP 2024年03月14日

发布过程没问题的,拓扑检查时只去除了重复线。
下面是网络服务的权重设置信息

在idesktop里进行最佳路径分析时是否成功呢?

在iDesktop好像是有问题的broken heart

1、路径和行驶引导信息能查出来吗?输出窗口报错什么呢?

2、建议对数据进行拓扑检查,修复弧段的拓扑错误。

路径查不出来,我检查了拓扑也没有错误

1、您试试最佳路径站点选择近一点的两个点,或者路径较简单的两个点,看能不能查询出路径

2、在构建网络数据集之前的原始线数据有没有做过线数据集拓扑处理,建议您按照文档重新构建网络数据集试试:https://blog.csdn.net/supermapsupport/article/details/131681536

我试过了选择距离比较近的两个点,以及也试了在网络线上选择节点,都查询不出路径。重新检查拓扑构建网络也是一样的结果。

应该是您的数据里存在大量环路,可以通过以下方案解决:

1、交通分析 ->环境设置 -> 检查环路 -> 打断(注意,检查环路功能需要数据有流向字段,没有流向可以在环境设置里创建流向,流程可参考:https://help.supermap.com/iDesktopX/1101/zh/tutorial/Network/AboutDirection

2、换用最新版idesktopX进行最佳路径分析,新版桌面端在进行最佳路径分析时可以选择忽略环路进行分析,下载地址:http://support.supermap.com.cn/DownloadCenter/DownloadPage.aspx?id=2550

您好,我试了将网络图层和poi图层单独加到地图中可以查询到路径。但是放在做好的地图中就不行

您好,您使用的iDesktop具体是什么版本呢,可以在【文件】—【关于】中复制具体的版本号。

我看您截图中的大版本为 iDesktop 11i 2022,于是用【版本: 11.0.1.1028.43635 x64(SuperMap iObjects .NET: 11.0.1.98023)】进行测试,没出现您上述的情况,将网络图层和poi图层放在做好的地图中也能正常查询到路径:

如果方便的话可以将具体的版本号和数据发送给我,我帮您测试一下,我的邮箱:1335950271@qq.com  如果数据保密的话,您可以删除部分数据,只要能重现问题即可。

...