Skip to content

Commit

Permalink
fix: 修复 LayerPopup followCursor 默认值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
heiyexing committed May 8, 2024
1 parent 788d74b commit 07aedd3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/demos/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { MapRender as control } from './control';
export { MapRender as layerPopup } from './layerPopup';
export { MapRender as marker } from './marker';
export { MapRender as swipe } from './swipe';
62 changes: 62 additions & 0 deletions examples/demos/components/layerPopup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { LayerPopup, PointLayer, Scene } from '@antv/l7';
import * as allMap from '@antv/l7-maps';
import type { RenderDemoOptions } from '../../types';

export function MapRender(options: RenderDemoOptions) {
const scene = new Scene({
id: 'map',
renderer: options.renderer,
map: new allMap.GaodeMap({
style: 'light',
center: [121.435159, 31.256971],
zoom: 14.89,
minZoom: 10,
}),
});
scene.on('loaded', () => {
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json')
.then((res) => res.json())
.then((data) => {
const pointLayer = new PointLayer({
name: 'layer',
})
.source(data, {
parser: {
type: 'json',
x: 'longitude',
y: 'latitude',
},
})
.shape('name', [
'circle',
'triangle',
'square',
'pentagon',
'hexagon',
'octogon',
'hexagram',
'rhombus',
'vesica',
])
.size('unit_price', [10, 25])
.color('name', ['#5B8FF9', '#5CCEA1', '#5D7092', '#F6BD16', '#E86452'])
.style({
opacity: 1,
strokeWidth: 2,
});

scene.addLayer(pointLayer);

const layerPopup = new LayerPopup({
items: [
{
layer: 'layer',
fields: ['name', 'count'],
},
],
});

scene.addPopup(layerPopup);
});
});
}
3 changes: 1 addition & 2 deletions packages/component/src/popup/layerPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ export default class LayerPopup extends Popup<ILayerPopupOption> {
}

protected getDefault(option: Partial<ILayerPopupOption>): ILayerPopupOption {
const isHoverTrigger = option.trigger === 'hover';

const isHoverTrigger = option.trigger !== 'click';
return {
...super.getDefault(option),
trigger: 'hover',
Expand Down

0 comments on commit 07aedd3

Please sign in to comment.