Skip to content

Commit

Permalink
feat(Map): 支持绑定 styleimagemissing 事件
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxingkang committed Jan 27, 2024
1 parent 1af6809 commit 091535d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/Map/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const MapEventMap: EventMapping = {
onPitchEnd: 'pitchend',

onWheel: 'wheel',
onStyleImageMissing: 'styleimagemissing',
};

export const MapEventList = Object.keys(MapEventMap) as KeysOfUnion<EventMapping>[];
2 changes: 1 addition & 1 deletion src/components/Map/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Map } from './map';
export { MapContext } from './context';
export type { MapProps } from './types';
export type { MapProps, MapEvents } from './types';
12 changes: 11 additions & 1 deletion src/components/Map/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import React from 'react';
import type { MapboxOptions, MapEventType } from 'mapbox-gl';
import type { Map, Style, MapboxOptions, MapEventType } from 'mapbox-gl';
import type { KeysOfUnion } from '../../types';

export type { KeysOfUnion } from '../../types';

export type SupplementMapEventType = {
styleimagemissing: {
id: string;
target: Map;
style: Style;
type: 'styleimagemissing';
};
};

export type MapEvents = {
onError: (e: MapEventType['error']) => void;

Expand Down Expand Up @@ -72,6 +81,7 @@ export type MapEvents = {
onPitchEnd: (e: MapEventType['pitchend']) => void;

onWheel: (e: MapEventType['wheel']) => void;
onStyleImageMissing: (e: SupplementMapEventType['styleimagemissing']) => void;
};

export type EventMapping = { [T in keyof MapEvents]: string };
Expand Down

0 comments on commit 091535d

Please sign in to comment.