简体   繁体   English

这个问题的解决方案是什么“加载资源失败:net::ERR_CONNECTION_REFUSED http://localhost:8989/route?.....”

[英]what is the solution to this problem "failed to load resource: net::ERR_CONNECTION_REFUSED http://localhost:8989/route?....."

I have a problem with my program.我的程序有问题。 this is a program about geographic information system that uses the LeatlefJs library, I also use the letlef routing machine feature.这是一个使用LeatlefJs库的地理信息系统程序,我也使用了letlef路由机功能。 the problem is the system can't display the route it should be able to display, I don't really understand.问题是系统不能显示它应该能显示的路线,我不太明白。 this is the script.这是脚本。

        function getDirectRoute(index, callbackFunction){
            var dari = marker_awal.getLatLng().lat + "," + marker_awal.getLatLng().lng;
            var tujuan = markerCabang[index].getLatLng().lat + "," + markerCabang[index].getLatLng().lng;
            $.ajax({
                  type: "GET",
                  url: "http://localhost:8989/route?point=" + dari + "&point=" + tujuan + "&points_encoded=false&instructions=false&vehicle=motorcycle&ch.disable=true&weighting=shortest&algorithm=alternative_route",
                  dataType: 'json',
                  contentType: "application/json",
                  success: function (data) {
                    successReveived++;
                    var coordinates = data.paths[0].points.coordinates;
                    tempDistance = 0;      
                    for(var j=0; j<coordinates.length; j++){
                        if(j==0){
                            tempDistance += euclidean(marker_awal.getLatLng().lat, marker_awal.getLatLng().lng, coordinates[j][1], coordinates[j][0]);
                        } else {
                            tempDistance += euclidean(coordinates[j-1][1], coordinates[j-1][0], coordinates[j][1], coordinates[j][0]);
                        }
                    }
                    distanceGH[index] = data.paths[0].distance;
                    distanceManual[index] = tempDistance.toFixed(4);
                    
                    if(successReveived == markerCabang.length && typeof(callbackFunction == 'function')){
                        callbackFunction();
                    }
                  }
            });
        } 

the error is like this错误是这样的

failed to load resource: net::ERR_CONNECTION_REFUSED http://localhost:8989/route?point=3.611967691620835,98.67254734039308&point=3.611126,98.67548&points_encoded=false&instructions=false&vehicle=motorcycle&ch.disable=true&weighting=shortest&algorithm=alternative_route未能加载资源:net::ERR_CONNECTION_REFUSED http://localhost:8989/route?point=3.611967691620835,98.67254734039308&point=3.611126,98.67548&points_encoded=false&instructions=false&vehicle=motorcycle&ch.disable=true&weighting=shortest&algorithm=

(I cannot comment yet, so trying to help you with an answer) (我还不能评论,所以试图帮助你回答)

  1. Make sure you have a working valid backend to respond for the JS library (see https://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/ for valid backends)确保您有一个有效的后端来响应 JS 库(有关有效后端,请参阅https://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/
  2. Try entering the URL directly in your browser (without Leaflet or anything else): http://localhost:8989/route -> You should see JSON output, even if it says malformed or invalid request.尝试直接在浏览器中输入 URL(不带 Leaflet 或其他任何内容):http://localhost:8989/route -> 您应该会看到 JSON 输出,即使它显示格式错误或无效请求。 If you are having the network issue here already you need to check the network layer (eg firewalls, port binding of the backend etc.), continue if thats not the case.如果您在这里已经遇到网络问题,您需要检查网络层(例如防火墙、后端的端口绑定等),如果不是这样,请继续。
  3. Open the network tab in your browsers DEV tools (F12) and filter all connections to your backend.在您的浏览器开发工具 (F12) 中打开网络选项卡并过滤到您的后端的所有连接。 Now try the map / leafletJS and check for additional information in that tab.现在尝试使用 map/leafletJS 并检查该选项卡中的其他信息。 You might see an error that your browser blocked the request due to something related to Cross-Origin-Requests (CORS).由于与跨域请求 (CORS) 相关的原因,您可能会看到浏览器阻止请求的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 向“http://localhost:3000/”发出 GET 请求时出错“加载资源失败:net::ERR_CONNECTION_REFUSED ... delete.js” - error when making GET request to 'http://localhost:3000/' “Failed to load resource: net::ERR_CONNECTION_REFUSED … delete.js” Webkit浏览器无法加载资源:net :: ERR_CONNECTION_REFUSED - Webkit Browsers Failed to load resource: net::ERR_CONNECTION_REFUSED 从本地主机获取资源失败:net :: ERR_CONNECTION_REFUSED - Failed to load resource: net::ERR_CONNECTION_REFUSED when fetching from localhost AxiosError:加载资源失败:net::ERR_CONNECTION_REFUSED - AxiosError : Failed to load resource: net::ERR_CONNECTION_REFUSED POST http://localhost:9000/ net::ERR_CONNECTION_REFUSED - POST http://localhost:9000/ net::ERR_CONNECTION_REFUSED GET http://localhost:5000/user net::ERR_CONNECTION_REFUSED - GET http://localhost:5000/user net::ERR_CONNECTION_REFUSED 无法加载资源:net::ERR_CONNECTION_REFUSED 仅适用于来自 instagram API 的选择性图像 - Failed to load resource: net::ERR_CONNECTION_REFUSED for only selective images from instagram API 发出GET请求时出错“无法加载资源:net :: ERR_CONNECTION_REFUSED” - error when making GET request “Failed to load resource: net::ERR_CONNECTION_REFUSED” 无法加载资源:Net::ERR_CONNECTION_REFUSED on NodeJs ,AngularJs Web 应用程序 - Failed to load resource: net::ERR_CONNECTION_REFUSED on NodeJs ,AngularJs Web Application 在看似没有改变之后,正在工作的 function 现在正在加载资源失败:net::ERR_CONNECTION_REFUSED - After changing seemingly nothing, a function that was working is now getting Failed to load resource: net::ERR_CONNECTION_REFUSED
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM