File tree Expand file tree Collapse file tree 8 files changed +54
-49
lines changed
Expand file tree Collapse file tree 8 files changed +54
-49
lines changed Original file line number Diff line number Diff line change 1+ import { Config } from "./types" ;
2+
3+ export const CONFIG : Config = {
4+ position : "bottomright" ,
5+ } ;
Original file line number Diff line number Diff line change 1+ import { FC } from "react" ;
2+ import { ZoomControl } from "react-leaflet" ;
3+ import { useSelector } from "react-redux" ;
4+
5+ import { CONFIG } from "./config" ;
6+ import { checkIsWithZoomControl } from "./selectors" ;
7+
8+ export const ZoomControls : FC = ( ) => {
9+ const isWithZoomControl = useSelector ( checkIsWithZoomControl ) ;
10+
11+ if ( ! isWithZoomControl ) {
12+ return null ;
13+ }
14+
15+ return < ZoomControl { ...CONFIG } /> ;
16+ } ;
Original file line number Diff line number Diff line change 1+ import { State } from "@/js/types" ;
2+
3+ export const checkIsWithZoomControl = ( state : State ) => {
4+ return state . geomapSettings . featuresConfiguration . isWithZoomControl ;
5+ } ;
Original file line number Diff line number Diff line change 1+ import { Control } from "leaflet" ;
2+
3+ export type Config = Control . ZoomOptions ;
Original file line number Diff line number Diff line change 11import { Config } from "./types" ;
22
33export const CONFIG : Config = {
4- MAP : {
5- center : [ 45.1 , 4.1 ] ,
6- zoom : 4 ,
7- maxZoom : 17 ,
8- minZoom : 2 ,
9- maxBounds : [
10- [ - 85 , - 180 ] ,
11- [ 85 , 180 ] ,
12- ] ,
13- maxBoundsViscosity : 1.0 ,
14- worldCopyJump : true ,
15- keyboard : false ,
16- zoomControl : false ,
17- } ,
18- ZOOM_CONTROL : {
19- position : "bottomright" ,
20- } ,
4+ center : [ 45.1 , 4.1 ] ,
5+ zoom : 4 ,
6+ maxZoom : 17 ,
7+ minZoom : 2 ,
8+ maxBounds : [
9+ [ - 85 , - 180 ] ,
10+ [ 85 , 180 ] ,
11+ ] ,
12+ maxBoundsViscosity : 1.0 ,
13+ worldCopyJump : true ,
14+ keyboard : false ,
15+ zoomControl : false ,
2116} ;
Original file line number Diff line number Diff line change 11import "leaflet/dist/leaflet.css" ;
22
33import { FC } from "react" ;
4- import { MapContainer , ZoomControl } from "react-leaflet" ;
5- import { useSelector } from "react-redux" ;
4+ import { MapContainer } from "react-leaflet" ;
65
76import { CONFIG } from "./config" ;
87import { HeightContainer } from "./HeightContainer" ;
98import { Layer } from "./Layer" ;
109import { Pins } from "./Pins" ;
11- import { getGeomapFeaturesSettings } from "./selectors " ;
10+ import { ZoomControls } from "./ZoomControls " ;
1211
13- const { MAP , ZOOM_CONTROL } = CONFIG ;
14-
15- export const Geomap : FC = ( ) => {
16- const { isWithZoomControl } = useSelector ( getGeomapFeaturesSettings ) ;
17-
18- return (
19- < HeightContainer >
20- < MapContainer { ...MAP } className = "geomap_container" >
21- { isWithZoomControl && < ZoomControl { ...ZOOM_CONTROL } /> }
22- < Layer />
23- < Pins />
24- </ MapContainer >
25- </ HeightContainer >
26- ) ;
27- } ;
12+ export const Geomap : FC = ( ) => (
13+ < HeightContainer >
14+ < MapContainer { ...CONFIG } className = "geomap_container" >
15+ < ZoomControls />
16+ < Layer />
17+ < Pins />
18+ </ MapContainer >
19+ </ HeightContainer >
20+ ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1- import { Control , MapOptions } from "leaflet" ;
1+ import { MapOptions } from "leaflet" ;
22
3- type MapConfig = Required <
3+ export type Config = Required <
44 Pick <
55 MapOptions ,
66 | "center"
@@ -14,10 +14,3 @@ type MapConfig = Required<
1414 | "zoomControl"
1515 >
1616> ;
17-
18- type ZoomControlConfig = Control . ZoomOptions ;
19-
20- export interface Config {
21- MAP : MapConfig ;
22- ZOOM_CONTROL : ZoomControlConfig ;
23- }
You can’t perform that action at this time.
0 commit comments