diff --git a/packages/core/src/services/interaction/InteractionService.ts b/packages/core/src/services/interaction/InteractionService.ts index 83daafc089..a602b450a6 100644 --- a/packages/core/src/services/interaction/InteractionService.ts +++ b/packages/core/src/services/interaction/InteractionService.ts @@ -61,6 +61,7 @@ export default class InteractionService extends EventEmitter // hammertime.on('panmove', this.onPanmove); // hammertime.on('panend', this.onPanend); // hammertime.on('pinch', this.onPinch); + $containter.addEventListener('touchstart', this.onTouch); $containter.addEventListener('mousemove', this.onHover); $containter.addEventListener('click', this.onHover); $containter.addEventListener('mousedown', this.onHover); @@ -85,6 +86,15 @@ export default class InteractionService extends EventEmitter $containter.removeEventListener('contextmenu', this.onHover); } } + private onTouch = (target: TouchEvent) => { + const touch = target.touches[0]; + // @ts-ignore + this.onHover({ + x: touch.pageX, + y: touch.pageY, + type: 'touch', + }); + }; private onHover = ({ x, y, type }: MouseEvent) => { const $containter = this.mapService.getMapContainer(); @@ -120,7 +130,9 @@ export default class InteractionService extends EventEmitter } return; } - + if (type === 'touch') { + type = 'click'; + } this.emit(InteractionEvent.Hover, { x, y, lngLat, type }); }; } diff --git a/packages/l7/demo/polygon.html b/packages/l7/demo/polygon.html index 12a8a2a2d5..05b669618e 100644 --- a/packages/l7/demo/polygon.html +++ b/packages/l7/demo/polygon.html @@ -11,9 +11,10 @@ } #map { position: absolute; - top: 0; - bottom: 0; - width: 100%; + top: 0, + left: 0, + right: 0, + bottom: 0, } { + alert('加载完成'); + + const color = [ 'rgb(255,255,217)', 'rgb(237,248,177)', 'rgb(199,233,180)', 'rgb(127,205,187)', 'rgb(65,182,196)', 'rgb(29,145,192)', 'rgb(34,94,168)', 'rgb(12,44,132)' ]; const layer = new L7.PolygonLayer({}) .source(data) @@ -115,6 +120,7 @@ opacity: 1.0 }); scene.addLayer(layer); + }); diff --git a/packages/renderer/package.json b/packages/renderer/package.json index 24434de420..eaf15005e8 100644 --- a/packages/renderer/package.json +++ b/packages/renderer/package.json @@ -30,7 +30,7 @@ "inversify": "^5.0.1", "lodash": "^4.17.15", "reflect-metadata": "^0.1.13", - "regl": "^1.3.11" + "regl": "1.3.11" }, "gitHead": "a5d354b66873f700730248d015c5e539c54b34b7", "publishConfig": {