Skip to content

Commit df810fa

Browse files
committed
refator: ♻️ maxzoom prop added and code refactoring
1 parent b188b21 commit df810fa

File tree

8 files changed

+39
-399
lines changed

8 files changed

+39
-399
lines changed

packages/naksha-components-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "naksha-components-react",
3-
"version": "4.6.1-beta.21",
3+
"version": "5.0.0",
44
"author": "harshzalavadiya",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",
@@ -24,8 +24,8 @@
2424
"@biodiv-platform/naksha-gmaps-draw": "4.5.3",
2525
"@biodiv-platform/naksha-gmaps-view": "4.4.9",
2626
"@biodiv-platform/naksha-maplibre-draw": "5.0.10",
27-
"@biodiv-platform/naksha-maplibre-layers": "5.0.1",
28-
"@biodiv-platform/naksha-maplibre-view": "5.0.2",
27+
"@biodiv-platform/naksha-maplibre-layers": "5.0.3",
28+
"@biodiv-platform/naksha-maplibre-view": "5.0.3",
2929
"@biodiv-platform/tsconfig": "4.4.9"
3030
},
3131
"devDependencies": {

packages/naksha-maplibre-layers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@biodiv-platform/naksha-maplibre-layers",
3-
"version": "5.0.1",
3+
"version": "5.0.3",
44
"author": "harshzalavadiya",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",

packages/naksha-maplibre-layers/src/components/map/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default function Map() {
2828
hover.onHover(event);
2929
};
3030

31+
console.info("NakshaMaplibreLayers props");
32+
3133
return (
3234
<div className={tw`h-full w-full relative bg-gray-100`}>
3335
{mp.loadToC && <Sidebar />}
@@ -38,6 +40,7 @@ export default function Map() {
3840
initialViewState={viewState}
3941
style={{ width: "100%", height: "100%" }}
4042
mapStyle={layer.mapStyle}
43+
maxZoom={layer.maxZoom}
4144
onClick={onMapClick}
4245
onMouseMove={handleOnMouseMove}
4346
>

packages/naksha-maplibre-layers/src/components/sidebar/settings/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ export default function SettingsTabPanel() {
1010
const { layer } = useLayers();
1111
const { t } = useT();
1212

13-
const handleOnStyleChange = (e) => layer.setMapStyle(e.target.value);
14-
13+
const handleOnStyleChange = (e) => {
14+
layer.setMapStyle(e.target.value);
15+
layer.setMaxZoom(
16+
layer.mapStyles.find((ms) => ms.style === e.target.value)?.maxZoom
17+
);
18+
};
1519
return (
1620
<div className={tw`w-full p-4 flex flex-col gap-4`}>
1721
<SelectInput

packages/naksha-maplibre-layers/src/hooks/use-layers.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ interface LayersContextProps {
2626
setIsInfoBarOpen;
2727
layer: {
2828
mapStyle?;
29-
mapStyles?;
3029
setMapStyle;
30+
31+
maxZoom?;
32+
setMaxZoom?;
33+
34+
mapStyles?;
3135
featuresAtLatLng;
3236
all: GeoserverLayer[];
3337
setAll;
@@ -84,6 +88,7 @@ export const LayersProvider = ({ mp: _mp, children }: LayersProviderProps) => {
8488
mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : defaultMapStyles;
8589

8690
const [mapStyle, setMapStyle] = useState(styles[mp?.mapStyle || 0]?.style);
91+
const [maxZoom, setMaxZoom] = useState(styles[mp?.mapStyle || 0]?.maxZoom);
8792
const [selectionStyle, setSelectionStyle] = useState<string>(
8893
SELECTION_STYLE.TOP
8994
);
@@ -331,6 +336,8 @@ export const LayersProvider = ({ mp: _mp, children }: LayersProviderProps) => {
331336
mapStyle,
332337
featuresAtLatLng,
333338
setMapStyle,
339+
maxZoom,
340+
setMaxZoom,
334341
mapStyles: styles,
335342
all: layers,
336343
setAll: setLayers,

packages/naksha-maplibre-view/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@biodiv-platform/naksha-maplibre-view",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"author": "arun",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",

packages/naksha-maplibre-view/src/components/map.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export default function Map(props: NakshaMaplibreViewProps) {
2626
);
2727

2828
const mapTile = props.mapStyles ? props.mapStyles : defaultMapStyles;
29-
const mapStyle = mapTile[selectedMapStyleIdx]?.style;
29+
const selectedMapTile = mapTile[selectedMapStyleIdx];
30+
const mapStyle = selectedMapTile?.style;
31+
const maxZoom = selectedMapTile?.maxZoom;
3032

3133
const onDataChange = () => {
3234
if (!props.data || !mapv) return;
@@ -39,7 +41,7 @@ export default function Map(props: NakshaMaplibreViewProps) {
3941
onDataChange();
4042
}, [props.data]);
4143

42-
const handleStyleChange = (idx) => {
44+
const handleStyleChange = (idx: number) => {
4345
setSelectedMapStyleIdx(idx);
4446
};
4547

@@ -50,6 +52,7 @@ export default function Map(props: NakshaMaplibreViewProps) {
5052
initialViewState={viewState}
5153
style={{ width: "100%", height: "100%" }}
5254
mapStyle={mapStyle}
55+
maxZoom={maxZoom}
5356
onLoad={onDataChange}
5457
>
5558
<NavControl position="bottom-right" showZoom={true} showCompass={true} />

0 commit comments

Comments
 (0)