【问题标题】:Accessing ArcGIS data over HTTP通过 HTTP 访问 ArcGIS 数据
【发布时间】:2020-09-30 20:56:01
【问题描述】:

我正在尝试使用 GIS 数据构建地图数据 React 应用程序。我正在访问公共 GIS 端点。

端点是http://gis.infrastructure.gov.au/infrastructure/rest/services/KeyFreightRoute/KFR/MapServer/0

在本地开发方面,它运行良好。但是,一旦推送到现场,它就会返回错误:net::ERR_CONNECTION_REFUSED。因为它是一个 HTTP 端点。

The ArcGIS docs describe a solution 使用配置,我已经包含以下代码:

        esriConfig.request.interceptors.push({
          // set the `urls` property to the URL of the FeatureLayer so that this
          // interceptor only applies to requests made to the FeatureLayer URL
          urls: featureLayerUrl,
          // use the BeforeInterceptorCallback to check if the query of the
          // FeatureLayer has a maxAllowableOffset property set.
          // if so, then set the maxAllowableOffset to 0
          before: function (params) {
            if (params.requestOptions.query.maxAllowableOffset) {
              params.requestOptions.query.maxAllowableOffset = 0;
            }
          },
          // use the AfterInterceptorCallback to check if `ssl` is set to 'true'
          // on the response to the request, if it's set to 'false', change
          // the value to 'true' before returning the response
          after: function (response) {
            if (!response.ssl) {
              console.log('not ssl');
              response.ssl = true;
            }
          },
        });

但是,它仍然无法正常工作!?事实上,console.log('not ssl') 甚至没有登录实时站点(但它正在登录 localhost)。

如何访问 HTTP GIS 端点?

【问题讨论】:

    标签: rest http arcgis arcgis-js-api arcgis-server


    【解决方案1】:

    这更多的是浏览器限制而不是 GIS 特定问题。如果您当前的 URL 栏有“HTTPS”,则不允许该页面访问 HTTP 资源 - 浏览器强制执行此作为安全措施。你有两个选择:

    1. 说服该网站(“gis.infrastructure.gov.au”)的所有者启用 HTTPS。这是当今的标准做法,而且相当简单。他们应该这样做。
    2. 您可以在自己的服务器上运行像Esri Resource Proxy 这样的代理。这样,您的应用程序将通过 HTTPS 访问 url(因为您的服务器使用 HTTPS 保护),但随后服务器在服务器站点上发出 HTTP 请求,从而绕过浏览器安全限制

    【讨论】:

      猜你喜欢
      • 2022-11-29
      • 2013-07-07
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-21
      • 2017-12-20
      相关资源
      最近更新 更多