Created
April 30, 2018 14:33
-
-
Save ca0v/c34efdc9a3d8a4aa456e10ff29a86a30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dojoDeclare = require("dojo/_base/declare"); | |
import DynamicMapServiceLayer = require("esri/layers/DynamicMapServiceLayer"); | |
import TiledMapServiceLayer = require("esri/layers/TiledMapServiceLayer"); | |
import Stateful = require("dojo/Stateful"); | |
import lang = require("dojo/_base/lang"); | |
import infor = require("../../../gis.map.ext"); | |
import { MapExtent } from "../../../models"; | |
import * as Models from "../../../models"; | |
import Extent = require("esri/geometry/Extent"); | |
import TileInfo = require("esri/layers/TileInfo"); | |
import SpatialReference = require("esri/SpatialReference"); | |
import Map = require("esri/map"); | |
let h$ = infor.h$; | |
class H8DynamicMapServiceLayer extends DynamicMapServiceLayer { | |
private _callbackid = 0; | |
private status = ""; | |
constructor(options: { | |
internalMap: Models.InternalMap | |
}) { | |
super(options); | |
lang.mixin(this, options); | |
this.loaded = true; | |
this.onLoad(this); | |
} | |
getImageUrl(extent: Extent, width: number, height: number, callback: Function) { | |
var imageExtent, | |
cbid = ++this._callbackid; | |
let asImageData = (url: string) => { | |
if (0 === url.indexOf("data:image")) { | |
return url; | |
} | |
return h$.combine(this.url, url); | |
}; | |
imageExtent = new MapExtent(extent.xmin, extent.ymin, extent.xmax, extent.ymax); | |
if (0 === width * height) | |
return; | |
this.set("status", "loading"); | |
infor.gis.hansen.setMapEvent("refresh-2018", { | |
extent: imageExtent, | |
layers: [this.internalMap.getLayer(this.id)], | |
custdata: width + ":" + height, | |
callback: (state) => { | |
var mapimage = infor.gis.hansen.processImageResponse(state); | |
if (cbid == this._callbackid) { | |
callback(asImageData(mapimage)); | |
this.set("status", "loaded"); | |
} | |
}, | |
errback: (err) => { | |
this.set("error", err.Message); | |
} | |
}); | |
return ""; | |
} | |
} | |
class H8TiledLayer extends H8DynamicMapServiceLayer { | |
// TODO | |
} | |
class LayerFactory { | |
constructor(options: any) { | |
// have a support ticket regarding tiling (Case number: 02108026) | |
return options.tileSize ? new H8DynamicMapServiceLayer(options) : new H8DynamicMapServiceLayer(options); | |
} | |
} | |
export = LayerFactory; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment