diff --git a/dev-demos/bugs/point/demos/shape.tsx b/dev-demos/bugs/point/demos/shape.tsx new file mode 100644 index 0000000000..06621024a6 --- /dev/null +++ b/dev-demos/bugs/point/demos/shape.tsx @@ -0,0 +1,79 @@ +// @ts-ignore +import { PointLayer, Scene,Popup } from '@antv/l7'; +// @ts-ignore +import { GaodeMap, Mapbox } from '@antv/l7-maps'; +import React, { useEffect } from 'react'; + +export default () => { + // @ts-ignore + useEffect( async () => { + const response = await fetch( + 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json', + ); + let shapeType = '01' + const scene = new Scene({ + id: 'map', + map: new GaodeMap({ + center: [121.4, 31.258134], + zoom: 14, + pitch: 0, + style: 'normal', + doubleClickZoom:false, + }), + }); + scene.addImage( + '00', + 'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*g8cUQ7pPT9YAAAAAAAAAAAAAARQnAQ', + ); + scene.addImage( + '01', + 'https://gw.alipayobjects.com/mdn/rms_fcd5b3/afts/img/A*LTcXTLBM7kYAAAAAAAAAAAAAARQnAQ', + ); + scene.addImage( + '02', + 'https://gw.alipayobjects.com/zos/bmw-prod/904d047a-16a5-461b-a921-98fa537fc04a.svg', + ); + const data = await response.json(); + const newData = data.map((item: any) => { + item.type = ['00', '01', '02'][Math.floor(Math.random() * 3)]; + return item; + }); + const imageLayer = new PointLayer({ + autoFit:false + }) + .source(newData, { + parser: { + type: 'json', + x: 'longitude', + y: 'latitude', + }, + }) + .shape('type', (v: any) => { + return shapeType; + }) + .active(false) + .size(20); + scene.addLayer(imageLayer); + setTimeout(()=>{ + shapeType = '02'; + // imageLayer.shape('type', (v: any) => { + // console.log(1111,shapeType) + // return shapeType; + // }) + imageLayer.shape('02'); + // scene.render() + + },2000) + + }, []); + return ( +
+ ); + }; + \ No newline at end of file diff --git a/dev-demos/bugs/point/shape.md b/dev-demos/bugs/point/shape.md new file mode 100644 index 0000000000..f6611edc2e --- /dev/null +++ b/dev-demos/bugs/point/shape.md @@ -0,0 +1,2 @@ +### Point - Shape + \ No newline at end of file diff --git a/packages/core/src/services/config/ConfigService.ts b/packages/core/src/services/config/ConfigService.ts index ca809d5069..637ab85dfd 100644 --- a/packages/core/src/services/config/ConfigService.ts +++ b/packages/core/src/services/config/ConfigService.ts @@ -16,6 +16,7 @@ const defaultSceneConfig: Partial = { logoVisible: true, antialias: true, stencil: true, + isMini: false, preserveDrawingBuffer: false, pickBufferScale: 1.0, fitBoundsOptions: { diff --git a/packages/core/src/services/config/IConfigService.ts b/packages/core/src/services/config/IConfigService.ts index 34196b6a19..bc77419efc 100644 --- a/packages/core/src/services/config/IConfigService.ts +++ b/packages/core/src/services/config/IConfigService.ts @@ -11,6 +11,7 @@ export interface ISceneConfig extends IRenderConfig { map: IMapWrapper; logoPosition?: PositionName; logoVisible?: boolean; + isMini?: boolean; // 是否是小程序场景 animate?: boolean; fitBoundsOptions?: unknown; pickBufferScale?: number; diff --git a/packages/scene/src/index.ts b/packages/scene/src/index.ts index a5cd45e792..8031fe78e0 100644 --- a/packages/scene/src/index.ts +++ b/packages/scene/src/index.ts @@ -32,7 +32,7 @@ import { } from '@antv/l7-core'; import { MaskLayer } from '@antv/l7-layers'; import { ReglRendererService } from '@antv/l7-renderer'; -import { DOM, isMini } from '@antv/l7-utils'; +import { DOM, isMini, setMiniScene } from '@antv/l7-utils'; import { Container } from 'inversify'; import BoxSelect, { BoxSelectEventList } from './boxSelect'; import ILayerManager from './ILayerManager'; @@ -99,6 +99,7 @@ class Scene ); this.popupService = sceneContainer.get(TYPES.IPopupService); this.boxSelect = new BoxSelect(this, {}); + setMiniScene(config?.isMini|| false); if (isMini) { this.sceneService.initMiniScene(config); diff --git a/packages/site/docs/api/scene.zh.md b/packages/site/docs/api/scene.zh.md index a97da22367..bcfae6aaf4 100644 --- a/packages/site/docs/api/scene.zh.md +++ b/packages/site/docs/api/scene.zh.md @@ -91,6 +91,11 @@ const scene = new L7.Scene({ 是否保留缓冲区数据 `boolean` `false`。 +### isMini + _boolean_ **可选** _default: false_ + +是否小程序模式 `boolean` `false`,目前仅支持支付宝 + ## Layer 方法 ### addLayer(layer): void 增加图层对象 diff --git a/packages/utils/src/mini-adapter/index.ts b/packages/utils/src/mini-adapter/index.ts index 6eb5d64460..b06a36ad4c 100644 --- a/packages/utils/src/mini-adapter/index.ts +++ b/packages/utils/src/mini-adapter/index.ts @@ -29,6 +29,11 @@ import { $XMLHttpRequest as $XMLHttpRequest2 } from './XMLHttpRequest'; import { globalWindow, l7globalThis } from './global'; +export let isMiniScene = false; +export function setMiniScene(flag: boolean) { + isMiniScene = flag; +} + // 判断时候是支付宝小程序环境 ( my.isFRM == true smallfish H5+ ) export const isMiniAli = // @ts-ignore @@ -42,7 +47,7 @@ export const isWeChatMiniProgram = wx !== null && (typeof wx.request !== 'undefined' || typeof wx.miniProgram !== 'undefined'); -export const isMini = isMiniAli || isWeChatMiniProgram; +export const isMini = (isMiniAli || isWeChatMiniProgram) && isMiniScene; export const miniWindow = { atob,