Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webmap): add addLayer onAdded option
- Loading branch information
Showing
7 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useRef } from 'react'; | ||
|
||
import { useNgwMapContext } from './context'; | ||
import { mapControlCreator } from './mapControlCreator'; | ||
|
||
import type { ReactNode } from 'react'; | ||
import type { ControlOptions, ToggleControlOptions } from '@nextgis/webmap'; | ||
|
||
interface MapControlProps extends ToggleControlOptions, ControlOptions { | ||
children?: ReactNode; | ||
} | ||
|
||
export function ToggleControl<P extends MapControlProps = MapControlProps>( | ||
props: P, | ||
) { | ||
const context = useNgwMapContext(); | ||
const el = document.createElement('div'); | ||
const portal = useRef(el); | ||
|
||
function createControl() { | ||
return context.ngwMap.createToggleControl(props); | ||
} | ||
|
||
return mapControlCreator({ ...props, context, portal, createControl }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters