zoukankan      html  css  js  c++  java
  • openlayer加载arcgis服务

    1、ArcGIS动态服务

    import ImageLayer from 'ol/layer/Image';
    import CustomImageArcGISRest from "./CustomImageArcGISRest";
    
    function  createDynamicArcGISLayer  (url, zIndex, radio) {
      if (!radio) radio = 1.0;
      return new ImageLayer({
        source: new CustomImageArcGISRest({
          ratio: radio,
          url: url
        }),
        zIndex
      });
    }
    CustomImageArcGISRest.js内容(改写原来的ImageArcGISRest)
    import ImageArcGISRest from 'ol/source/ImageArcGISRest'
    import {appendParams} from "ol/uri";
    import {assert} from "ol/asserts";
    
    
    /**
     *
     * 兼容非标准URL形式的MapServer
     *
     *
     */
    class CustomImageArcGISRest extends ImageArcGISRest {
    
    
      constructor(opt_options) {
        super(opt_options);
      }
    
    
      getRequestUrl_(extent, size, pixelRatio, projection, params) {
        // ArcGIS Server only wants the numeric portion of the projection ID.
        const srid = projection.getCode().split(':').pop();
    
        params['SIZE'] = size[0] + ',' + size[1];
        params['BBOX'] = extent.join(',');
        params['BBOXSR'] = srid;
        params['IMAGESR'] = srid;
        params['DPI'] = Math.round(90 * pixelRatio);
    
        const url = this.url_;
    
    
        let _modifiedUrl = url
          .replace(/MapServer/?$/, 'MapServer/export')
          .replace(/ImageServer/?$/, 'ImageServer/exportImage');
    
        if (_modifiedUrl == url) {
          _modifiedUrl = url.concat('/export');
        }
    
        const modifiedUrl = _modifiedUrl;
    
        if (modifiedUrl == url) {
          assert(false, 50); // `options.featureTypes` should be an Array
        }
    
        return appendParams(modifiedUrl, params);
      }
    
    }
    
    
    export default CustomImageArcGISRest;
    2、ArcGIS切片服务
    
    
    import XYZ from 'ol/source/XYZ'
    import Tile from 'ol/layer/Tile'
    import TileGrid from 'ol/tilegrid/TileGrid'

    function
    createTiledArcGISLayer (url, zIndex, _EPSG) { let SRID = _EPSG || '4528'; return new Tile({ source: new XYZ({ url: `${url}/tile/{z}/{y}/{x}`, projection: get(`EPSG:${SRID}`), tileGrid: new TileGrid(window.applicationConfig.tileInfo), }), zIndex }); }

    关于window.applicationConfig.tileInfo要看你的服务配置,例如

        tileInfo: {
          tileSize: 256,
          origin: [34876800, 10002100],
          extent: [40453740.474700004, 3442540.7754500005, 40557073.819, 3541460.3122000005],
          resolutions: [
            132.2919312505292,
            76.35146092731352,
            38.17573046365676,
            19.08786523182838,
            9.543932616046483,
            4.771966307890949,
            2.3859831539454746,
            1.1929915769727373,
            0.5964957886186606,
            0.14912394722081113
          ]
        },



  • 相关阅读:
    我就是想找个人聊聊天,说说我这近四年来的经历-02
    我就是想找个人聊聊天,说说我这近四年来的经历
    Padas交叉表新增二级分类小计
    superset开启本地缓存filesystem
    Superset连接Impala数据源
    Python实现网站注册验证码生成类
    Python爬虫原理
    Superset导出pivot_table到excel
    Superset导出CSV文件中文或日文乱码
    Linux下如何高效删除一个几十G的文本文件的最后一行或几行
  • 原文地址:https://www.cnblogs.com/yangzhengier/p/14336568.html
Copyright © 2011-2022 走看看