案例中"最佳路径分析"报找不到一个josn文件

0 投票
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)
10月 10, 2017 分类:  432次浏览 | 用户: 咖啡加盐 (3 分)

2 个回答

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

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

<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";试一下

...