123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- var __extends = (this && this.__extends) || (function() {
- var extendStatics = Object.setPrototypeOf ||
- ({
- __proto__: []
- }
- instanceof Array && function(d, b) {
- d.__proto__ = b;
- }) ||
- function(d, b) {
- for (var p in b)
- if (b.hasOwnProperty(p)) d[p] = b[p];
- };
- return function(d, b) {
- extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
- var c = arguments.length,
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
- d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else
- for (var i = decorators.length - 1; i >= 0; i--)
- if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- define([
- "require",
- "exports",
- "esri/core/tsSupport/declareExtendsHelper",
- "esri/core/tsSupport/decorateHelper",
- "esri/core/accessorSupport/decorators",
- "esri/geometry/Extent",
- "esri/layers/BaseTileLayer",
- "esri/layers/support/TileInfo",
- "esri/geometry/SpatialReference",
- "dojo/promise/all",
- "esri/request"
- ], function(require, exports, __extends, __decorate, decorators, Extent, BaseTileLayer, TileInfo, SpatialReference, all, esriRequest) {
- "use strict";
- return function(_super) {
- function SHCMapServiceLayer() {
- var _self = _super.call(this) || this;
- _self.token = null;
- _self.tileInfo =
- new TileInfo({
- "dpi": 96,
- "format": "png",
- "spatialReference": SpatialReference.WebMercator,
- "size": [512, 512],
- "origin": {
- "x": -66000,
- "y": 75000
- },
- "lods": [{
- "level": 0,
- "resolution": 270.93387520108377,
- "scale": 1024000
- }, {
- "level": 1,
- "resolution": 135.46693760054188,
- "scale": 512000
- }, {
- "level": 2,
- "resolution": 67.73346880027094,
- "scale": 256000
- }, {
- "level": 3,
- "resolution": 33.86673440013547,
- "scale": 128000
- }, {
- "level": 4,
- "resolution": 16.933367200067735,
- "scale": 64000
- }, {
- "level": 5,
- "resolution": 8.466683600033868,
- "scale": 32000
- }, {
- "level": 6,
- "resolution": 4.233341800016934,
- "scale": 16000
- }, {
- "level": 7,
- "resolution": 2.116670900008467,
- "scale": 8000
- }, {
- "level": 8,
- "resolution": 1.0583354500042335,
- "scale": 4000
- }, {
- "level": 9,
- "resolution": 0.5291677250021167,
- "scale": 2000
- }, {
- "level": 10,
- "resolution": 0.26458386250105836,
- "scale": 1000
- }, {
- "level": 11,
- "resolution": 0.13229193125052918,
- "scale": 500
- }],
-
- });
- return _self;
- };
- __extends(SHCMapServiceLayer, _super);
- SHCMapServiceLayer.prototype._getTileUrl = function(level, row, col) {
- var lt_x = this.tileInfo.origin.x + col * this.tileInfo.lods[level].resolution * this.tileInfo.size[0];
- var lt_y = this.tileInfo.origin.y - (row * this.tileInfo.lods[level].resolution * this.tileInfo.size[1]);
- var rb_x = this.tileInfo.origin.x + (col + 1) * this.tileInfo.lods[level].resolution * this.tileInfo.size[0];
- var rb_y = this.tileInfo.origin.y - ((row + 1) * this.tileInfo.lods[level].resolution * this.tileInfo.size[1]);
- var bbox = lt_x + "," + rb_y + "," + rb_x + "," + lt_y
- return this.url + "/export?bbox=" + bbox + "&size=" + this.tileInfo.size[0] + "," + this.tileInfo.size[1]
- + "&bboxSR=" + "" + "&imageSR=" + ""
- + "&dpi=96&format=png&transparent=true&layerDefs=&time=&layerTimeOptions=&dynamicLayers=&gdbVersion=&mapScale=&f=image";
- if (this.token != null)
- _url += "?token=" + this.token;
- };
- SHCMapServiceLayer.prototype.fetchTile = function(level, row, col, options) {
- var url = this._getTileUrl(level, row, col);
- return esriRequest(url, {
- responseType: "image",
- allowImageDataAccess: true,
- signal: options.signal
- })
- .then(function(response) {
- var image = response.data;
- var width = this.tileInfo.size[0];
- var height = this.tileInfo.size[0];
- var canvas = document.createElement("canvas");
- var context = canvas.getContext("2d");
- canvas.width = width;
- canvas.height = height;
- context.drawImage(image, 0, 0, width, height);
- return canvas;
- }.bind(this));
- };
- return SHCMapServiceLayer = __decorate([decorators.subclass("SHCMapServiceLayer")], SHCMapServiceLayer);
- }(decorators.declared(BaseTileLayer));
- });
|