首页 / 浏览问题 / 云GIS / 问题详情
交通换乘初次加载的一个小问题
16EXP 2018年07月02日

程序运行时,起点终点已经写好了,然后点击换成策略的时候不能显示方案,必须重新填一下起点终点才可以出来,控制台会报这样的错,是什么问题啊

1个回答

您好,没有读到框里边的值,感觉是逻辑这块有问题。
4,524EXP 2018年07月02日
可是我是按照示例代码改的啊,就是改了服务的路径和起点终点的值,不应该出错呀,逻辑有什么问题啊
你怎么写的我看下
//起点搜索文本提示信息框
        function addStartSugText() {
            var inputDiv = $("<div class='start_end_input'></div>")
            $("<span>起点:</span>").appendTo(inputDiv);
            var input = $("<input type='search' width='60px' id='startInput' value='西门' text='26,506699.0264,4341115.7752'></input>");
            var p = new SuperMap.Geometry.Point(506699.0264, 4341115.7752);//点的实例化
            startLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(p.x, p.y), iconstart));
            input.keyup(findStartStops);
            input.keydown(updateStartInputByResult);
            input.appendTo(inputDiv);
            inputDiv.appendTo($("#func"));

            var dataList = $("<div id='startSugPopup' class='sugpopup'></div>");
            $("<ul id='startSugList' class='dropList'></ul>").appendTo(dataList);
            dataList.appendTo(inputDiv);

            function findStartStops(event) {
                clear();
                var code = event.keyCode;
                if (isStartKey) return;
                if (code === 37 || code === 38 || code === 39 || code === 40 || code === 13) return;
                markerLayer.clearMarkers();
                startLayer.clearMarkers();
                vectorLayer.removeAllFeatures();
                $("#startInput").attr("text", "");
                var txt = $("#endInput").attr("text");
                if (txt) {
                    var end = txt.split(",");
                    endLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(end[1], end[2]), iconend));
                }

                var list = $("#startSugList");
                list.empty();
                var popup = $("#startSugPopup");
                var startName = event.target.value;
                if (!startName) {
                    popup.css("display", "none");
                    return;
                }

                var params = new SuperMap.REST.StopQueryParameters({
                    keyWord: startName,
                    returnPosition: true
                });
                var iserver = new SuperMap.REST.StopQueryService(url1, {
                    eventListeners: {
                        processCompleted: stopQuerySucceed,
                        processFailed: stopQueryFailed
                    }
                });
                iserver.processAsync(params);

                //返回根据模糊的地名搜索得到的跟地名有关的所有公交站点的结果
                function stopQuerySucceed(stopQueryEvent) {
                    popup.addClass("show").css("display", "block");
                    if (!stopQueryEvent.result.transferStopInfos.length) {
                        $("<li>未找到匹配的起点</li>").appendTo(list);
                        noStart = true;
                    } else {
                        noStart = false;
                        for (var i = 0, len = stopQueryEvent.result.transferStopInfos.length; i < len; i++) {
                            var station = stopQueryEvent.result.transferStopInfos[i];
                            var value = station.stopID + "," + station.position.x + "," + station.position.y;
                            $("<li id='" + value + "'>" + station.name + "</li>").appendTo(list);
                            list.find("li").click(function () {
                                var input = $("#startInput");
                                input.val($(this).text());
                                input.attr("text", $(this).attr("id"));
                                $("#startSugList").empty();
                                popup.removeClass("show");
                                var arr = $(this).attr("id").split(",");
                                startLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(arr[1], arr[2]), iconstart));
                                map.setCenter(new SuperMap.LonLat(arr[1], arr[2]), 0);
                            }).hover(
                                function () {
                                    $("#startSugList li.dropListMouseOver").removeClass("dropListMouseOver");
                                    $(this).addClass("dropListMouseOver");
                                },
                                function () {
                                    $(this).removeClass("dropListMouseOver");
                                }
                            );
                        }
                    }
                }

                function stopQueryFailed(result) {
                    widgets.alert.showAlert(result, false);
                }
            }

            function updateStartInputByResult(event) {
                clear();
                var code = event.keyCode, current, input;
                if (code === 38 || code === 40) {
                    isStartKey = true;
                } else if (code === 13) {
                } else {
                    isStartKey = false;
                    return;
                }
                current = $("#startSugList li.dropListMouseOver");
                input = $("#startInput");
                if (code === 13) {
                    if (current.length !== 0) {
                        input.val(current.text());
                        input.attr("text", current.attr("id"));
                        $("#startSugList").empty();
                        $("#startSugPopup").removeClass("show");
                        var arr = current.attr("id").split(",");
                        startLayer.clearMarkers();
                        startLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(arr[1], arr[2]), iconstart));
                        map.setCenter(new SuperMap.LonLat(arr[1], arr[2]), 0);
                    }
                    return;
                }
                if (code === 38) {
                    if (current.length !== 0) {
                        current.removeClass("dropListMouseOver");
                        current = current.prev();
                        if (current.length === 0) {
                            current = $("#startSugPopup li:last-child");
                        }
                    } else {
                        current = $("#startSugPopup li:last-child");
                    }
                    current.addClass("dropListMouseOver");
                    input.val(current.text());
                    input.attr("text", current.attr("id"));
                } else if (code === 40) {
                    if (current.length !== 0) {
                        current.removeClass("dropListMouseOver");
                        current = current.next();
                        if (current.length === 0) {
                            current = $("#startSugPopup li:first-child");
                        }
                    } else {
                        current = $("#startSugPopup li:first-child");
                    }
                    current.addClass("dropListMouseOver");
                    input.val(current.text());
                    input.attr("text", current.attr("id"));
                }
            }
        }

终点文本框的写法是一样的
到底是怎么回事啊,好奇怪啊
点击按钮以后的网络请求什么样看下
//添加下拉菜单
        function addDropDownMenu(name) {
            $("<div class='btn-group'><a class='btn btn-info dropdown-toggle' data-toggle='dropdown' href='#'>" + name + "<span class='caret'></span></a><ul class='dropdown-menu' id='menuList'></ul>").appendTo($("#func"));
        }

        function addDropDownMenuItem(name, callback) {
            var li = $("<li><a href='javascript:void(0)'>" + name + "</a></li>");
            li.click(callback);
            li.appendTo($("#menuList"));
        }

是这个吗

这些东西

是不是出错了,没有响应吗

不正常,有这个错误:500 内部服务器错误,在 HTTP 协议中,500 Internal Server Error 是表示服务器端错误的响应状态码,意味着所请求的服务器遇到意外的情况并阻止其执行请求。

你text里写错了吧,你那是26吗

这个26是什么意思啊,我看示例代码里写了26
啊,26是他的id,我把id写错了,现在已经改好了,谢谢你啊
...