首页 / 浏览问题 / 云GIS / 问题详情
案例中"最佳路径分析"报找不到一个josn文件
3EXP 2017年10月10日
iserver/services/map-changchun/rest/maps/%E9%95%BF%E6%98%A5%E5%B8%82%E5%8C%BA%E5%9B%BE.json Failed to load resource: the server responded with a status of 404 (Not Found)

2 个回答

报错是没有这个地图(长春市区图),建议检查服务地址,在上一级iserver/services/map-changchun/rest/maps查看是否有这个地图。
ps: iServer deploy包不带示例服务。
1,780EXP 2017年10月10日
本身示例是可以用的,只是我把它拷贝到本地做成demo的时候就会。   var host = document.location.toString().match(/file:\/\//) ? "http://192.168.1.8:8090" : 'http://' + document.location.host;  路径我已经改成自己的地址了。还不可以。示例中是有这个地图的。
您好,您url是“/iserver/services/map-changchun/rest/maps/长春市区图”这样的吗?url里的“长春市区图”要写成中文,不要写成“%E6%98%A5%E5”这样的符号。
4,524EXP 2017年10月10日

您好,示例代码是这样的:

<script type="text/javascript">
        var host = document.location.toString().match(/file:\/\//) ? "http://192.168.1.8:8090" : 'http://' + document.location.host;
        var local, map, layer, vectorLayer, markerLayer,
        drawPoint, select,
        nodeArray = [], pathTime, pathListIndex = 0, routeCompsIndex = 0,
        style = {
            strokeColor: "#304DBE",
            strokeWidth: 3,
            pointerEvents: "visiblePainted",
            fill: false
        },
        styleGuidePoint = {
            pointRadius: 10,
            externalGraphic: "./images/walk.png"
        },
        styleGuideLine = {
            strokeColor: "#25FF25",
            strokeWidth: 6,
            fill: false
        },
        url1 = host + "/iserver/services/map-changchun/rest/maps/长春市区图",
        url2 = host + "/iserver/services/transportationanalyst-sample/rest/networkanalyst/RoadNet@Changchun";
        function init() {
            vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
            drawPoint = new SuperMap.Control.DrawFeature(vectorLayer, SuperMap.Handler.Point);
            select = new SuperMap.Control.SelectFeature(vectorLayer, { onSelect: onFeatureSelect, onUnselect: onFeatureUnselect });
            drawPoint.events.on({ "featureadded": drawCompleted });
            map = new SuperMap.Map("map", {
                controls: [
                new SuperMap.Control.LayerSwitcher(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                }),
                drawPoint,
                select], units: "m"
            });
            layer = new SuperMap.Layer.TiledDynamicRESTLayer("Changchun", url1, { transparent: true, cacheEnabled: true }, { maxResolution: "auto" });
            layer.events.on({ "layerInitialized": addLayer });
            markerLayer = new SuperMap.Layer.Markers("Markers");
        }

        function addLayer() {
            map.addLayers([layer, vectorLayer, markerLayer]);
            map.setCenter(new SuperMap.LonLat(4503.6240321526, -3861.911472192499), 1);
        }
        function selectPoints() {
            clearElements();
            drawPoint.activate();
        }
        function drawCompleted(drawGeometryArgs) {
            var point = drawGeometryArgs.feature.geometry,
            size = new SuperMap.Size(44, 33),
            offset = new SuperMap.Pixel(-(size.w / 2), -size.h),
            icon = new SuperMap.Icon("../theme/images/marker.png", size, offset);
            markerLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon));
            nodeArray.push(point);
        }

     
    </script>

红色的路径是我改成本地服务器的地址,但是调试的时候,js会报:iserver/services/map-changchun/rest/maps/%E9%95%BF%E6%98%A5%E5%B8%82%E5%8C%BA%E5%9B%BE.json Failed to load resource: the server responded with a status of 404 (Not Found)

这个路径的地址应该是:http://192.168.1.8:8090/iserver/services/map-changchun/rest/maps/%E9%95%BF%E6%98%A5%E5%B8%82%E5%8C%BA%E5%9B%BE.json

可是由于不知道这个josn如果生成的,导致我不知道如何修改这个路径。

你把var host = document.location.toString().match(/file:\/\//) ? "http://192.168.1.8:8090" : 'http://' + document.location.host;这段删掉,url改成 

url1="http://192.168.1.8:8090/iserver/services/map-changchun/rest/maps/长春市区图",
url2="http://192.168.1.8:8090/iserver/services/transportationanalyst-sample/rest/networkanalyst/RoadNet@Changchun";试一下

...