zoukankan      html  css  js  c++  java
  • arcgis js 加载动态层图片

    define([
    "dojo/_base/declare",
    "dojo/_base/lang",
    "esri/layers/DynamicMapServiceLayer",
    "esri/geometry/Extent"
    ], function(
    declare,
    lang,
    DynamicMapServiceLayer,
    Extent
    ) {
    return declare("DynamicMapSuperPost", DynamicMapServiceLayer, { // create DynamicMapLayer by extending esri.layers.TiledMapServiceLayer
    constructor:function(){
    this.spatialReference = new esri.SpatialReference({wkid:4490});
    this.initialExtent = this.fullExtent = new Extent({"xmin":109.3868865977334,"ymin":29.938091498799054,"xmax":117.6127404019528,"ymax":37.81307950094276,"spatialReference": this.spatialReference});
    this.loaded = true;
    this.onLoad(this);
    },
    getImageUrl: function(extent, width, height, callback) {
    var params = {
    //request: "GetMap",
    //transparent: true,
    format: "png",//"image/png",
    //bgcolor: "ffffff",
    //version: "1.1.1",
    layers: 'id1,id2,id3,id4',
    //styles: "default,default",
    //exceptions: "application/vnd.ogc.se_xml",

    //changing values
    bbox: extent.xmin + "," + extent.ymin + "," + extent.xmax + "," + extent.ymax,
    //bbox:'113.68330445912024,34.75990865047065,113.71526537935056,34.77527045072429',
    MAPID: 110,
    //GRAY:0,
    //LAYERHIDEOID:'`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^',
    //LAYERHIDEOID:'`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^`^',
    //srs: "EPSG:" + extent.spatialReference.wkid,
    width,
    height: height
    };
    var curParams = dojo.objectToQuery(params);

    var _self = this;
    var curentImgId = this._img_loading.id;
           //这个地方是使用了servlet返回动态层的png图片,原因是有些动态层是定制的,要符合他们要求
    var url = '../proxy';

    var xhr = new XMLHttpRequest();
    xhr.responseType = 'blob';
    xhr.open('POST', url, true);//POST请求,请求地址,是否异步
    xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
    xhr.onload = function (ev) {
    if (this.status == 200) {
    var data = this.response;
    var blob = new Blob();
    blob = data;
    var blobImage = window.URL.createObjectURL(blob);
    if (_self._img_loading && _self._img_loading.id == curentImgId) {
    callback(blobImage);
    } else {//缩放或移动中img被arcgis删除了,丢失dom节点
    window.URL.revokeObjectURL(blobImage);//释放
    }
    }
    }
    xhr.send(curParams);

    },
    _imgSrcFunc: function (a) {
    this._img_loading.src = a
    this._img_loading.onload = function () {
    window.URL.revokeObjectURL(this.src);//释放
    }
    }
    });
    });

  • 相关阅读:
    虚函数和纯虚函数
    MS CRM 2011中PartyList类型字段的实例化
    MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(4)
    MS CRM 2011的自定义与开发(12)——表单脚本扩展开发(2)
    MS CRM 2011的自定义和开发(10)——CRM web服务介绍(第二部分)——IOrganizationService(二)
    MS CRM 2011 SDK 5.08已经发布
    MS CRM 2011 Q2的一些更新
    最近很忙
    Microsoft Dynamics CRM 2011最近的一些更新
    补一篇,Update Rollup 12 终于发布了
  • 原文地址:https://www.cnblogs.com/aoeuy/p/9629143.html
Copyright © 2011-2022 走看看