Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Feat react #25

Merged
merged 4 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions docs/demo/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ export default () => {
>
<div
onClick={e => {
e.stopPropagation();
e.preventDefault();
// e.stopPropagation();
// e.preventDefault();
alert('我被点击了');
}}
>
<button>我能不能被点击</button>
<button
onClick={() => {
alert('b我被点击了');
}}
>
我能不能被点击
</button>
</div>
</Popup>
)}
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"name": "@antv/l7-react",
"version": "2.3.3",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/antvis/L7-react"
},
"scripts": {
"start": "dumi dev",
"docs:build": "dumi build",
Expand Down
2 changes: 1 addition & 1 deletion src/component/Control.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IControl, Logo, PositionName, Scale, Zoom, Layers } from '@antv/l7';
import React, { useRef, useEffect } from 'react';
import { useSceneValue } from './SceneContext';
interface IControlProps {
export interface IControlProps {
type: 'scale' | 'zoom' | 'logo' | 'layer';
position: PositionName;
[key: string]: any;
Expand Down
2 changes: 1 addition & 1 deletion src/component/CustomControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createPortal } from 'react-dom';
import { useSceneValue } from './SceneContext';
const { useEffect, useState } = React;

interface IColorLegendProps {
export interface IColorLegendProps {
position: PositionName;
className?: string;
style?: React.CSSProperties;
Expand Down
2 changes: 1 addition & 1 deletion src/component/LayerEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { useLayerValue } from './LayerContext';

const { useEffect } = React;
interface ILayerProps {
export interface ILayerProps {
type: string;
handler: (...args: any[]) => void;
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/LoadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { useSceneValue } from './SceneContext';

const { useEffect } = React;
interface ILoadImageProps {
export interface ILoadImageProps {
name: string;
url: IImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import { IMapConfig, ISceneConfig, Scene } from '@antv/l7';
// tslint:disable-next-line:no-submodule-imports
import { GaodeMap } from '@antv/l7-maps';
import React, { useRef, useEffect, useState } from 'react';
import { SceneContext } from './SceneContext';
interface IMapSceneConfig {
style?: React.CSSProperties;
className?: string;
map: Partial<IMapConfig>;
option?: Partial<ISceneConfig>;
children?: React.ReactNode;
onSceneLoaded?: (scene: Scene) => void;
}
import { SceneContext } from '../SceneContext';
import { IMapSceneConfig } from './interface';

const AMapScene = React.memo((props: IMapSceneConfig) => {
const { style, className, map, option, onSceneLoaded, children } = props;
const container = useRef<HTMLDivElement>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ import { IMapConfig, ISceneConfig, Scene } from '@antv/l7';
// tslint:disable-next-line:no-submodule-imports
import { GaodeMapV2 } from '@antv/l7-maps';
import React, { useRef, useEffect, useState } from 'react';
import { SceneContext } from './SceneContext';
interface IMapSceneConig {
style?: React.CSSProperties;
className?: string;
map: Partial<IMapConfig>;
option?: Partial<ISceneConfig>;
children?: React.ReactNode;
onSceneLoaded?: (scene: Scene) => void;
}
const AMapScene = React.memo((props: IMapSceneConig) => {
import { SceneContext } from '../SceneContext';
import { IMapSceneConfig } from './interface';

const AMapScene = React.memo((props: IMapSceneConfig) => {
const { style, className, map, option, onSceneLoaded, children } = props;
const container = useRef<HTMLDivElement>(null);
const [scene, setScene] = useState<Scene>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import { IMapConfig, ISceneConfig, Scene } from '@antv/l7';
// tslint:disable-next-line:no-submodule-imports
import { Map } from '@antv/l7-maps';
import React, { useRef, useEffect, useState } from 'react';
import { SceneContext } from './SceneContext';
interface IMapSceneConfig {
style?: React.CSSProperties;
className?: string;
map: Partial<IMapConfig>;
option?: Partial<ISceneConfig>;
children?: React.ReactNode;
onSceneLoaded?: (scene: Scene) => void;
}
import { SceneContext } from '../SceneContext';
import { IMapSceneConfig } from './interface';

const MapScene = React.memo((props: IMapSceneConfig) => {
const { style, className, map, option, onSceneLoaded, children } = props;
const container = useRef<HTMLDivElement>(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import { IMapConfig, ISceneConfig, Scene, Zoom } from '@antv/l7';
// tslint:disable-next-line:no-submodule-imports
import { Mapbox } from '@antv/l7-maps';
import React, { createElement, createRef, useEffect, useState } from 'react';
import { SceneContext } from './SceneContext';
interface IMapSceneConfig {
style?: React.CSSProperties;
className?: string;
map: Partial<IMapConfig>;
option?: Partial<ISceneConfig>;
children?: React.ReactNode;
onSceneLoaded?: (scene: Scene) => void;
}
import { SceneContext } from '../SceneContext';
import { IMapSceneConfig } from './interface';

const MapboxScene = React.memo((props: IMapSceneConfig) => {
const { style, className, map, option, onSceneLoaded } = props;
const container = createRef();
Expand Down
9 changes: 9 additions & 0 deletions src/component/MapScene/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IMapConfig, ISceneConfig, Scene } from '@antv/l7';
export interface IMapSceneConfig {
style?: React.CSSProperties;
className?: string;
map: Partial<IMapConfig>;
option?: Partial<ISceneConfig>;
children?: React.ReactNode;
onSceneLoaded?: (scene: Scene) => void;
}
2 changes: 1 addition & 1 deletion src/component/Marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import * as React from 'react';
import { createPortal } from 'react-dom';
import { SceneContext } from './SceneContext';
interface IMarkerProps {
export interface IMarkerProps {
option?: IMarkerOption;
lnglat: ILngLat | number[];
onMarkerLoaded?: (marker: IMarker) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/component/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import * as React from 'react';
import { createPortal } from 'react-dom';
import { SceneContext } from './SceneContext';
interface IPopupProps {
export interface IPopupProps {
option?: Partial<IPopupOption>;
lnglat: number[] | { lng: number; lat: number };
lngLat?: number[] | { lng: number; lat: number };
Expand Down
2 changes: 1 addition & 1 deletion src/component/Scene.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IMapWrapper, Scene } from '@antv/l7';
import React, { useRef, useEffect, useState } from 'react';
import { SceneContext } from './SceneContext';
interface IMapSceneConfig {
export interface IMapSceneConfig {
style?: Partial<React.CSSProperties>;
className?: string;
map: IMapWrapper;
Expand Down
2 changes: 1 addition & 1 deletion src/component/SceneEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { useSceneValue } from './SceneContext';

const { useEffect } = React;
interface ILayerProps {
export interface ILayerProps {
type: string;
handler: (...args: any[]) => void;
}
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export * from './component/SceneContext';
export { default as AMapScene } from './component/AMapScene';
export { default as MapboxScene } from './component/MapboxScene';
export { default as AMapSceneV2 } from './component/AMapSceneV2';
export { default as MapScene } from './component/MapScene';
export * from './component/MapScene/interface';
export { default as AMapScene } from './component/MapScene/AMapScene';
export { default as MapboxScene } from './component/MapScene/MapboxScene';
export { default as AMapSceneV2 } from './component/MapScene/AMapSceneV2';
export { default as MapScene } from './component/MapScene/MapScene';
export { default as Scene } from './component/Scene';
export { default as Control } from './component/Control';
export { default as CustomControl } from './component/CustomControl';
Expand Down