MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / constructor

Method constructor

src/openlayers/overlay/HeatMap.js:42–103  ·  view source on GitHub ↗
(name, opt_options)

Source from the content-addressed store, hash-verified

40export class HeatMap extends ImageCanvasSource {
41
42 constructor(name, opt_options) {
43 var options = opt_options ? opt_options : {};
44 super({
45 attributions: options.attributions || "Map Data <span>© SuperMap iServer</span> with <span>© SuperMap iClient</span>",
46 canvasFunction: canvasFunctionInternal_,
47 logo: Util.getOlVersion() === '4' ? options.logo : null,
48 projection: options.projection,
49 ratio: options.ratio,
50 resolutions: options.resolutions,
51 state: options.state
52 });
53
54 function canvasFunctionInternal_(extent, resolution, pixelRatio, size, projection) { // eslint-disable-line no-unused-vars
55 var mapWidth = size[0] * pixelRatio;
56 var mapHeight = size[1] * pixelRatio;
57
58 this.rootCanvas.width = this.maxWidth = mapWidth;
59 this.rootCanvas.height = this.maxHeight = mapHeight;
60 if (!this.features) {
61 return this.rootCanvas;
62 }
63 this.pixelRatio = pixelRatio;
64
65 //记录偏移量
66 var width = this.map.getSize()[0] * pixelRatio;
67 var height = this.map.getSize()[1] * pixelRatio;
68 this.offset = [(mapWidth - width) / 2 / pixelRatio, (mapHeight - height) / 2 / pixelRatio];
69
70 this.updateHeatPoints(resolution);
71
72 return this.rootCanvas;
73 }
74
75 //初始化成员变量
76 this.canvasFunctionInternal_ = canvasFunctionInternal_;
77 this.features = [];
78 this.name = name;
79 if (!options.map) {
80 throw new Error('options.map is not found.');
81 }
82 this.map = options.map;
83 // this.TFEvents = options.TFEvents || [];
84 this.id = options.id ? options.id : CommonUtil.createUniqueID("HeatMapSource_");
85 this.opacity = options.opacity ? options.opacity : 1;
86 this.colors = options.colors ? options.colors : ['blue', 'cyan', 'lime', 'yellow', 'red'];
87 this.useGeoUnit = options.useGeoUnit ? options.useGeoUnit : false;
88 this.radius = options.radius ? options.radius : 50;
89 this.featureWeight = options.featureWeight ? options.featureWeight : null;
90 this.maxWeight = null;
91 this.minWeight = null;
92 this.maxWidth = null;
93 this.maxHeight = null;
94
95 //创建热力图绘制面板
96 this.rootCanvas = document.createElement("canvas");
97 var mapSize = this.map.getSize();
98 this.rootCanvas.width = this.maxWidth = parseInt(mapSize[0]);
99 this.rootCanvas.height = this.maxHeight = parseInt(mapSize[1]);

Callers

nothing calls this directly

Calls 3

createElementMethod · 0.80
getSizeMethod · 0.80
getContextMethod · 0.45

Tested by

no test coverage detected