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

Method constructor

src/openlayers/overlay/Graphic.js:61–254  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

59 */
60export class Graphic extends ImageCanvasSource {
61 constructor(options) {
62 super({
63 attributions: options.attributions,
64 canvasFunction: canvasFunctionInternal_,
65 logo: Util.getOlVersion() === '4' ? options.logo : null,
66 projection: options.projection,
67 ratio: options.ratio,
68 resolutions: options.resolutions,
69 state: options.state
70 });
71 this.graphics = [].concat(options.graphics);
72 this.map = options.map;
73 CommonUtil.extend(this, options);
74 this.render = options.render || Renderer[0];
75 if (!Util.supportWebGL2()) {
76 this.render = Renderer[0];
77 }
78 this.highLightStyle = options.highLightStyle;
79 //是否支持高亮,默认支持
80 this.isHighLight = typeof options.isHighLight === 'undefined' ? true : options.isHighLight;
81 this.hitGraphicLayer = null;
82 this._forEachFeatureAtCoordinate = _forEachFeatureAtCoordinate;
83 this._options = options;
84 const me = this;
85 if (options.onClick) {
86 me.map.on('click', function(e) {
87 if (me.isDeckGLRender) {
88 const params = me.renderer.deckGL.pickObject({ x: e.pixel[0], y: e.pixel[1] });
89 options.onClick(params);
90 return;
91 }
92 const graphic = me.findGraphicByPixel(e, me);
93 if (graphic) {
94 options.onClick(graphic, e);
95 if (me.isHighLight) {
96 me._highLight(
97 graphic.getGeometry().getCoordinates(),
98 new Style({
99 image: graphic.getStyle()
100 }).getImage(),
101 graphic,
102 e.pixel
103 );
104 }
105
106 }
107 });
108 }
109 me.map.on('pointermove', function(e) {
110 if (me.isDeckGLRender) {
111 const params = me.renderer.deckGL.pickObject({ x: e.pixel[0], y: e.pixel[1] });
112 if (options.onHover) {
113 options.onHover(params);
114 }
115 }
116 });
117 //eslint-disable-next-line no-unused-vars
118 function canvasFunctionInternal_(extent, resolution, pixelRatio, size, projection) {

Callers

nothing calls this directly

Calls 7

extendMethod · 0.80
supportWebGL2Method · 0.80
findGraphicByPixelMethod · 0.80
_highLightMethod · 0.80
getGeometryMethod · 0.80
onMethod · 0.45
getStyleMethod · 0.45

Tested by

no test coverage detected