@zurigo/maps 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/google-maps.d.ts +3 -1
- package/dist/components/google-maps.d.ts.map +1 -1
- package/dist/components/google-maps.js +108 -162
- package/dist/components/google-maps.js.map +1 -1
- package/dist/lib/google-maps/config.d.ts +34 -31
- package/dist/lib/google-maps/config.d.ts.map +1 -1
- package/dist/lib/google-maps/config.js +54 -21
- package/dist/lib/google-maps/config.js.map +1 -1
- package/dist/lib/google-maps/geocoding-service.d.ts +3 -2
- package/dist/lib/google-maps/geocoding-service.d.ts.map +1 -1
- package/dist/lib/google-maps/geocoding-service.js +31 -38
- package/dist/lib/google-maps/geocoding-service.js.map +1 -1
- package/dist/lib/google-maps/hooks.d.ts +2 -2
- package/dist/lib/google-maps/hooks.d.ts.map +1 -1
- package/dist/lib/google-maps/hooks.js +29 -20
- package/dist/lib/google-maps/hooks.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RegionType } from "../lib/google-maps/config";
|
|
1
2
|
export interface GoogleMapsProps {
|
|
2
3
|
onPolygonComplete?: (polygon: google.maps.Polygon) => void;
|
|
3
4
|
onPolygonEdit?: (polygon: google.maps.Polygon) => void;
|
|
@@ -25,7 +26,8 @@ export interface GoogleMapsProps {
|
|
|
25
26
|
};
|
|
26
27
|
}>;
|
|
27
28
|
readOnly?: boolean;
|
|
29
|
+
region?: RegionType;
|
|
28
30
|
}
|
|
29
|
-
declare const GoogleMaps: ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center, zoom, onMapLoad, className, animateToLocation, showMeasurements, clearTrigger, existingPolygons, readOnly, }: GoogleMapsProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
declare const GoogleMaps: ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center, zoom, onMapLoad, className, animateToLocation, showMeasurements, clearTrigger, existingPolygons, readOnly, region, }: GoogleMapsProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
32
|
export default GoogleMaps;
|
|
31
33
|
//# sourceMappingURL=google-maps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-maps.d.ts","sourceRoot":"","sources":["../../src/components/google-maps.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-maps.d.ts","sourceRoot":"","sources":["../../src/components/google-maps.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAiB,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAyCtE,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC;IAC3D,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC;IACvD,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC;IACzD,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,KAAK,CAAC;QACvB,QAAQ,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACzC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC;KACzC,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,QAAA,MAAM,UAAU,GAAI,mLAcjB,eAAe,4CA+vEjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -9,7 +9,36 @@ const solar_panel_calculator_1 = require("../lib/solar-panel-calculator");
|
|
|
9
9
|
// Drawing constraints
|
|
10
10
|
const MIN_ZOOM_FOR_DRAWING = 18; // Minimum zoom level to allow drawing
|
|
11
11
|
const MAX_AREA_LIMIT = 10000; // Maximum area in m² for drawn shapes
|
|
12
|
-
|
|
12
|
+
// Shape styles
|
|
13
|
+
const RECTANGLE_STYLES = {
|
|
14
|
+
default: {
|
|
15
|
+
fillColor: "#1e40af",
|
|
16
|
+
fillOpacity: 0.3,
|
|
17
|
+
strokeColor: "#1e40af",
|
|
18
|
+
strokeWeight: 3,
|
|
19
|
+
},
|
|
20
|
+
selected: {
|
|
21
|
+
fillColor: "#dc2626",
|
|
22
|
+
fillOpacity: 0.6,
|
|
23
|
+
strokeColor: "#dc2626",
|
|
24
|
+
strokeWeight: 5,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const POLYGON_STYLES = {
|
|
28
|
+
default: {
|
|
29
|
+
fillColor: "#059669",
|
|
30
|
+
fillOpacity: 0.3,
|
|
31
|
+
strokeColor: "#059669",
|
|
32
|
+
strokeWeight: 2,
|
|
33
|
+
},
|
|
34
|
+
selected: {
|
|
35
|
+
fillColor: "#dc2626",
|
|
36
|
+
fillOpacity: 0.5,
|
|
37
|
+
strokeColor: "#dc2626",
|
|
38
|
+
strokeWeight: 3,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center, zoom, onMapLoad, className = "w-full h-full", animateToLocation = true, showMeasurements = false, clearTrigger, existingPolygons, readOnly = false, region = 'korea', }) => {
|
|
13
42
|
const mapRef = (0, react_1.useRef)(null);
|
|
14
43
|
const drawingManagerRef = (0, react_1.useRef)(null);
|
|
15
44
|
const polygonsRef = (0, react_1.useRef)([]);
|
|
@@ -19,6 +48,8 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
19
48
|
const capacityLabelsRef = (0, react_1.useRef)([]);
|
|
20
49
|
const panelLayoutOverlaysRef = (0, react_1.useRef)([]); // 패널 레이아웃 오버레이용
|
|
21
50
|
const rotationHandleRef = (0, react_1.useRef)(null);
|
|
51
|
+
const selectedRectangleRef = (0, react_1.useRef)(null);
|
|
52
|
+
const selectedPolygonRef = (0, react_1.useRef)(null);
|
|
22
53
|
const rotationListenerRef = (0, react_1.useRef)(null);
|
|
23
54
|
const currentShapeRef = (0, react_1.useRef)(null);
|
|
24
55
|
const [isAnimating, setIsAnimating] = (0, react_1.useState)(false);
|
|
@@ -30,7 +61,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
30
61
|
const [isRotating, setIsRotating] = (0, react_1.useState)(false);
|
|
31
62
|
// Suppress unused variable warning - redoStack is for future undo/redo implementation
|
|
32
63
|
void redoStack;
|
|
33
|
-
const mapOptions = (0, config_1.getMapOptions)(Object.assign({ center,
|
|
64
|
+
const mapOptions = (0, config_1.getMapOptions)(region, Object.assign({ center,
|
|
34
65
|
zoom, mapTypeId: "satellite", mapTypeControl: false }, (readOnly && {
|
|
35
66
|
disableDefaultUI: true, // 모든 기본 UI 숨기기
|
|
36
67
|
zoomControl: false, // 줌 컨트롤 숨기기
|
|
@@ -45,15 +76,11 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
45
76
|
if (!readOnly) {
|
|
46
77
|
initializeDrawingManager(mapInstance);
|
|
47
78
|
// Add map click listener to deselect shapes
|
|
48
|
-
mapInstance.addListener("click", (
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
deselectPolygon();
|
|
54
|
-
deselectRectangle();
|
|
55
|
-
}, 10);
|
|
56
|
-
}
|
|
79
|
+
mapInstance.addListener("click", () => {
|
|
80
|
+
// Add a small delay to allow shape click events to fire first
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
removeRotationHandle();
|
|
83
|
+
}, 50);
|
|
57
84
|
});
|
|
58
85
|
}
|
|
59
86
|
onMapLoad === null || onMapLoad === void 0 ? void 0 : onMapLoad(mapInstance);
|
|
@@ -104,18 +131,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
104
131
|
map.setZoom(18);
|
|
105
132
|
}
|
|
106
133
|
// Create polygon from saved geometry
|
|
107
|
-
const polygon = new google.maps.Polygon({
|
|
108
|
-
paths: polygonData.geometry,
|
|
109
|
-
fillColor: "#10b981",
|
|
110
|
-
fillOpacity: 0.4,
|
|
111
|
-
strokeWeight: 3,
|
|
112
|
-
strokeColor: "#059669",
|
|
113
|
-
clickable: false,
|
|
114
|
-
editable: false,
|
|
115
|
-
draggable: false,
|
|
116
|
-
map: map,
|
|
117
|
-
zIndex: 1000,
|
|
118
|
-
});
|
|
134
|
+
const polygon = new google.maps.Polygon(Object.assign(Object.assign({ paths: polygonData.geometry }, POLYGON_STYLES.default), { clickable: false, editable: false, draggable: false, map: map, zIndex: 1000 }));
|
|
119
135
|
// Store polygon reference
|
|
120
136
|
polygonsRef.current.push(polygon);
|
|
121
137
|
// Add capacity label if capacity data exists
|
|
@@ -151,7 +167,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
151
167
|
zIndex: 1,
|
|
152
168
|
clickable: true,
|
|
153
169
|
draggable: true,
|
|
154
|
-
editable:
|
|
170
|
+
editable: false,
|
|
155
171
|
},
|
|
156
172
|
rectangleOptions: {
|
|
157
173
|
fillColor: "#3b82f6",
|
|
@@ -161,7 +177,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
161
177
|
zIndex: 1,
|
|
162
178
|
clickable: true,
|
|
163
179
|
draggable: true,
|
|
164
|
-
editable:
|
|
180
|
+
editable: false,
|
|
165
181
|
},
|
|
166
182
|
});
|
|
167
183
|
drawingManager.setMap(mapInstance);
|
|
@@ -251,8 +267,8 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
251
267
|
addPolygonMeasurementsWithLayoutInfo(polygon, layoutInfo, layoutInfo.capacity, mapInstance);
|
|
252
268
|
}
|
|
253
269
|
onPolygonComplete === null || onPolygonComplete === void 0 ? void 0 : onPolygonComplete(polygon);
|
|
254
|
-
// Auto-select the newly created polygon
|
|
255
|
-
|
|
270
|
+
// Auto-select the newly created polygon immediately
|
|
271
|
+
selectPolygonWithMap(polygon, mapInstance);
|
|
256
272
|
});
|
|
257
273
|
drawingManager.addListener("rectanglecomplete", (rectangle) => {
|
|
258
274
|
drawingManager.setDrawingMode(null);
|
|
@@ -343,8 +359,8 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
343
359
|
paths: [sw, nw, ne, se],
|
|
344
360
|
});
|
|
345
361
|
onPolygonComplete === null || onPolygonComplete === void 0 ? void 0 : onPolygonComplete(polygonFromRect);
|
|
346
|
-
// Auto-select the newly created rectangle
|
|
347
|
-
|
|
362
|
+
// Auto-select the newly created rectangle immediately
|
|
363
|
+
selectRectangleWithMap(rectangle, mapInstance);
|
|
348
364
|
}
|
|
349
365
|
});
|
|
350
366
|
};
|
|
@@ -450,48 +466,56 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
450
466
|
capacityLabelsRef.current.push(capacityMarker);
|
|
451
467
|
};
|
|
452
468
|
// Polygon selection and editing functions
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}, 100);
|
|
469
|
+
// Helper functions for shape styling
|
|
470
|
+
const setShapeStyle = (shape, styleType, shapeType) => {
|
|
471
|
+
const styles = shapeType === "polygon" ? POLYGON_STYLES : RECTANGLE_STYLES;
|
|
472
|
+
const isSelected = styleType === "selected";
|
|
473
|
+
shape.setOptions(Object.assign(Object.assign({}, styles[styleType]), { editable: isSelected }));
|
|
459
474
|
};
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
strokeWeight: 2,
|
|
466
|
-
fillOpacity: 0.3,
|
|
467
|
-
});
|
|
475
|
+
const deselectShape = (shape, shapeType, setterFn, refSetter) => {
|
|
476
|
+
if (shape) {
|
|
477
|
+
setShapeStyle(shape, "default", shapeType);
|
|
478
|
+
setterFn(null);
|
|
479
|
+
refSetter.current = null;
|
|
468
480
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
});
|
|
476
|
-
setSelectedRectangle(null);
|
|
481
|
+
};
|
|
482
|
+
// Shape selection functions
|
|
483
|
+
const selectPolygonShape = (shape) => {
|
|
484
|
+
// Deselect current polygon if different
|
|
485
|
+
if (selectedPolygonRef.current && selectedPolygonRef.current !== shape) {
|
|
486
|
+
setShapeStyle(selectedPolygonRef.current, "default", "polygon");
|
|
477
487
|
}
|
|
488
|
+
// Deselect rectangle
|
|
489
|
+
deselectShape(selectedRectangleRef.current, "rectangle", setSelectedRectangle, selectedRectangleRef);
|
|
478
490
|
// Select new polygon
|
|
479
|
-
setSelectedPolygon(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
strokeWeight: 3,
|
|
483
|
-
fillOpacity: 0.5,
|
|
484
|
-
});
|
|
491
|
+
setSelectedPolygon(shape);
|
|
492
|
+
selectedPolygonRef.current = shape;
|
|
493
|
+
setShapeStyle(shape, "selected", "polygon");
|
|
485
494
|
};
|
|
486
|
-
const
|
|
487
|
-
if
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
strokeWeight: 2,
|
|
491
|
-
fillOpacity: 0.3,
|
|
492
|
-
});
|
|
493
|
-
setSelectedPolygon(null);
|
|
495
|
+
const selectRectangleShape = (shape) => {
|
|
496
|
+
// Deselect current rectangle if different
|
|
497
|
+
if (selectedRectangleRef.current && selectedRectangleRef.current !== shape) {
|
|
498
|
+
setShapeStyle(selectedRectangleRef.current, "default", "rectangle");
|
|
494
499
|
}
|
|
500
|
+
// Deselect polygon
|
|
501
|
+
deselectShape(selectedPolygonRef.current, "polygon", setSelectedPolygon, selectedPolygonRef);
|
|
502
|
+
// Select new rectangle
|
|
503
|
+
setSelectedRectangle(shape);
|
|
504
|
+
selectedRectangleRef.current = shape;
|
|
505
|
+
setShapeStyle(shape, "selected", "rectangle");
|
|
506
|
+
};
|
|
507
|
+
const selectPolygonWithMap = (polygon, mapInstance) => {
|
|
508
|
+
selectPolygonShape(polygon);
|
|
509
|
+
setTimeout(() => addRotationHandle(polygon, mapInstance), 100);
|
|
510
|
+
};
|
|
511
|
+
const selectRectangleWithMap = (rectangle, mapInstance) => {
|
|
512
|
+
selectRectangleShape(rectangle);
|
|
513
|
+
setTimeout(() => addRotationHandle(rectangle, mapInstance), 100);
|
|
514
|
+
};
|
|
515
|
+
const selectPolygon = (polygon) => {
|
|
516
|
+
selectPolygonShape(polygon);
|
|
517
|
+
};
|
|
518
|
+
const deselectPolygon = () => {
|
|
495
519
|
removeRotationHandle();
|
|
496
520
|
};
|
|
497
521
|
const savePolygonState = (polygon) => {
|
|
@@ -547,19 +571,10 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
547
571
|
lng: point.lng() + 0.0001,
|
|
548
572
|
});
|
|
549
573
|
}
|
|
550
|
-
const newPolygon = new google.maps.Polygon({
|
|
551
|
-
paths: coordinates,
|
|
552
|
-
fillColor: "#10b981",
|
|
553
|
-
fillOpacity: 0.3,
|
|
554
|
-
strokeWeight: 2,
|
|
555
|
-
strokeColor: "#059669",
|
|
556
|
-
clickable: true,
|
|
557
|
-
editable: true,
|
|
558
|
-
draggable: true,
|
|
559
|
-
map: map,
|
|
560
|
-
});
|
|
574
|
+
const newPolygon = new google.maps.Polygon(Object.assign(Object.assign({ paths: coordinates }, POLYGON_STYLES.default), { clickable: true, editable: false, draggable: true, map: map }));
|
|
561
575
|
polygonsRef.current.push(newPolygon);
|
|
562
|
-
newPolygon.addListener("click", () => {
|
|
576
|
+
newPolygon.addListener("click", (event) => {
|
|
577
|
+
event.stop(); // Prevent map click event
|
|
563
578
|
selectPolygon(newPolygon);
|
|
564
579
|
});
|
|
565
580
|
// Add drag listeners
|
|
@@ -604,48 +619,10 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
604
619
|
}
|
|
605
620
|
};
|
|
606
621
|
// Rectangle selection and editing functions
|
|
607
|
-
const selectRectangleWithMap = (rectangle, mapInstance) => {
|
|
608
|
-
selectRectangle(rectangle);
|
|
609
|
-
// Add rotation handle with map instance
|
|
610
|
-
setTimeout(() => {
|
|
611
|
-
addRotationHandle(rectangle, mapInstance);
|
|
612
|
-
}, 100);
|
|
613
|
-
};
|
|
614
622
|
const selectRectangle = (rectangle) => {
|
|
615
|
-
|
|
616
|
-
if (selectedPolygon) {
|
|
617
|
-
selectedPolygon.setOptions({
|
|
618
|
-
strokeColor: "#059669",
|
|
619
|
-
strokeWeight: 2,
|
|
620
|
-
fillOpacity: 0.3,
|
|
621
|
-
});
|
|
622
|
-
setSelectedPolygon(null);
|
|
623
|
-
}
|
|
624
|
-
// Deselect previous rectangle
|
|
625
|
-
if (selectedRectangle) {
|
|
626
|
-
selectedRectangle.setOptions({
|
|
627
|
-
strokeColor: "#1e40af",
|
|
628
|
-
strokeWeight: 3,
|
|
629
|
-
fillOpacity: 0.3,
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
// Select new rectangle
|
|
633
|
-
setSelectedRectangle(rectangle);
|
|
634
|
-
rectangle.setOptions({
|
|
635
|
-
strokeColor: "#dc2626",
|
|
636
|
-
strokeWeight: 4,
|
|
637
|
-
fillOpacity: 0.5,
|
|
638
|
-
});
|
|
623
|
+
selectRectangleShape(rectangle);
|
|
639
624
|
};
|
|
640
625
|
const deselectRectangle = () => {
|
|
641
|
-
if (selectedRectangle) {
|
|
642
|
-
selectedRectangle.setOptions({
|
|
643
|
-
strokeColor: "#1e40af",
|
|
644
|
-
strokeWeight: 3,
|
|
645
|
-
fillOpacity: 0.3,
|
|
646
|
-
});
|
|
647
|
-
setSelectedRectangle(null);
|
|
648
|
-
}
|
|
649
626
|
removeRotationHandle();
|
|
650
627
|
};
|
|
651
628
|
const saveRectangleState = (rectangle) => {
|
|
@@ -714,17 +691,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
714
691
|
const sw = bounds.getSouthWest();
|
|
715
692
|
// Create new bounds with slight offset
|
|
716
693
|
const newBounds = new google.maps.LatLngBounds(new google.maps.LatLng(sw.lat() + 0.0001, sw.lng() + 0.0001), new google.maps.LatLng(ne.lat() + 0.0001, ne.lng() + 0.0001));
|
|
717
|
-
const newRectangle = new google.maps.Rectangle({
|
|
718
|
-
bounds: newBounds,
|
|
719
|
-
fillColor: "#3b82f6",
|
|
720
|
-
fillOpacity: 0.3,
|
|
721
|
-
strokeWeight: 3,
|
|
722
|
-
strokeColor: "#1e40af",
|
|
723
|
-
clickable: true,
|
|
724
|
-
editable: true,
|
|
725
|
-
draggable: true,
|
|
726
|
-
map: map,
|
|
727
|
-
});
|
|
694
|
+
const newRectangle = new google.maps.Rectangle(Object.assign(Object.assign({ bounds: newBounds }, RECTANGLE_STYLES.default), { clickable: true, editable: false, draggable: true, map: map }));
|
|
728
695
|
rectanglesRef.current.push(newRectangle);
|
|
729
696
|
newRectangle.addListener("click", () => {
|
|
730
697
|
selectRectangle(newRectangle);
|
|
@@ -774,7 +741,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
774
741
|
if (!targetMap) {
|
|
775
742
|
return;
|
|
776
743
|
}
|
|
777
|
-
|
|
744
|
+
removeRotationHandleOnly(); // Remove existing handle only
|
|
778
745
|
// Update current shape reference
|
|
779
746
|
currentShapeRef.current = shape;
|
|
780
747
|
const center = getShapeCenter(shape);
|
|
@@ -844,7 +811,6 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
844
811
|
handleClick = rotationHandle.addListener("click", () => {
|
|
845
812
|
isDragging = true;
|
|
846
813
|
setIsRotating(true);
|
|
847
|
-
console.log("Rotation started - not clearing all panels");
|
|
848
814
|
// Use center position as initial reference for AdvancedMarkerElement
|
|
849
815
|
startAngle = 0; // Start from center
|
|
850
816
|
startRotationListeners();
|
|
@@ -857,7 +823,6 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
857
823
|
return;
|
|
858
824
|
isDragging = true;
|
|
859
825
|
setIsRotating(true);
|
|
860
|
-
console.log("Rotation started - not clearing all panels");
|
|
861
826
|
// Calculate initial angle from center to click position
|
|
862
827
|
startAngle = calculateAngle(center, event.latLng);
|
|
863
828
|
startRotationListeners();
|
|
@@ -895,10 +860,6 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
895
860
|
google.maps.event.removeListener(mapMouseUpListener);
|
|
896
861
|
mapMouseUpListener = null;
|
|
897
862
|
}
|
|
898
|
-
console.log("Rotation completed - redrawing all panels");
|
|
899
|
-
console.log("Selected polygon:", selectedPolygon);
|
|
900
|
-
console.log("Selected rectangle:", selectedRectangle);
|
|
901
|
-
console.log("Current shape ref:", currentShapeRef.current);
|
|
902
863
|
// Trigger edit callback for the rotated shape
|
|
903
864
|
const currentShape = currentShapeRef.current;
|
|
904
865
|
if (currentShape && currentShape instanceof google.maps.Polygon) {
|
|
@@ -927,14 +888,14 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
927
888
|
clearMeasurements();
|
|
928
889
|
}
|
|
929
890
|
// Redraw all shapes using the refresh function
|
|
930
|
-
console.log("Refreshing all labels and visualizations after rotation");
|
|
931
891
|
refreshAllLabelsAndVisualizationsWithCalculation(targetMap);
|
|
932
892
|
});
|
|
933
893
|
};
|
|
934
894
|
// Store listener reference for cleanup
|
|
935
895
|
rotationListenerRef.current = handleClick;
|
|
936
896
|
};
|
|
937
|
-
const
|
|
897
|
+
const removeRotationHandleOnly = () => {
|
|
898
|
+
// Remove rotation handle only, without deselecting shapes
|
|
938
899
|
if (rotationHandleRef.current) {
|
|
939
900
|
if (rotationHandleRef.current instanceof
|
|
940
901
|
google.maps.marker.AdvancedMarkerElement) {
|
|
@@ -949,9 +910,17 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
949
910
|
google.maps.event.removeListener(rotationListenerRef.current);
|
|
950
911
|
rotationListenerRef.current = null;
|
|
951
912
|
}
|
|
952
|
-
currentShapeRef.current = null;
|
|
953
913
|
setIsRotating(false);
|
|
954
914
|
};
|
|
915
|
+
const removeRotationHandle = () => {
|
|
916
|
+
removeRotationHandleOnly();
|
|
917
|
+
// Reset all selected shapes to default style using both state and ref
|
|
918
|
+
const currentPolygon = selectedPolygon || selectedPolygonRef.current;
|
|
919
|
+
const currentRectangle = selectedRectangle || selectedRectangleRef.current;
|
|
920
|
+
deselectShape(currentPolygon, "polygon", setSelectedPolygon, selectedPolygonRef);
|
|
921
|
+
deselectShape(currentRectangle, "rectangle", setSelectedRectangle, selectedRectangleRef);
|
|
922
|
+
currentShapeRef.current = null;
|
|
923
|
+
};
|
|
955
924
|
const getShapeCenter = (shape) => {
|
|
956
925
|
if (shape instanceof google.maps.Polygon) {
|
|
957
926
|
const path = shape.getPath();
|
|
@@ -1060,17 +1029,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
1060
1029
|
rectanglesRef.current.splice(rectIndex, 1);
|
|
1061
1030
|
}
|
|
1062
1031
|
// Create a new polygon with the rotated corners
|
|
1063
|
-
const rotatedPolygon = new google.maps.Polygon({
|
|
1064
|
-
paths: [rotatedSw, rotatedNw, rotatedNe, rotatedSe],
|
|
1065
|
-
fillColor: "#3b82f6",
|
|
1066
|
-
fillOpacity: 0.3,
|
|
1067
|
-
strokeWeight: 3,
|
|
1068
|
-
strokeColor: "#1e40af",
|
|
1069
|
-
clickable: true,
|
|
1070
|
-
editable: true,
|
|
1071
|
-
draggable: true,
|
|
1072
|
-
map: targetMap,
|
|
1073
|
-
});
|
|
1032
|
+
const rotatedPolygon = new google.maps.Polygon(Object.assign(Object.assign({ paths: [rotatedSw, rotatedNw, rotatedNe, rotatedSe] }, POLYGON_STYLES.default), { clickable: true, editable: true, draggable: true, map: targetMap }));
|
|
1074
1033
|
// Add to polygons array and set up listeners
|
|
1075
1034
|
polygonsRef.current.push(rotatedPolygon);
|
|
1076
1035
|
rotatedPolygon.addListener("click", (event) => {
|
|
@@ -1134,7 +1093,6 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
1134
1093
|
// Update current shape reference immediately
|
|
1135
1094
|
currentShapeRef.current = rotatedPolygon;
|
|
1136
1095
|
// Don't clear or draw panels during rotation - wait for rotation to complete
|
|
1137
|
-
console.log("Rectangle converted to polygon during rotation - not touching any panels");
|
|
1138
1096
|
// Trigger callback
|
|
1139
1097
|
onPolygonEdit === null || onPolygonEdit === void 0 ? void 0 : onPolygonEdit(rotatedPolygon);
|
|
1140
1098
|
};
|
|
@@ -1387,17 +1345,7 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
1387
1345
|
// 새로운 그리드 기반 패널 위치 정보 사용
|
|
1388
1346
|
if (layoutInfo.validPanelPositions &&
|
|
1389
1347
|
layoutInfo.validPanelPositions.length > 0) {
|
|
1390
|
-
const { rotationAngle,
|
|
1391
|
-
console.log("Polygon-aware panel layout:");
|
|
1392
|
-
console.log(`Total valid panels: ${validPanelPositions.length}`);
|
|
1393
|
-
console.log(`Rotation angle: ${(rotationAngle * 180) / Math.PI}°`);
|
|
1394
|
-
// 디버깅용 - 변 길이 출력
|
|
1395
|
-
if (edges && edges.length > 0) {
|
|
1396
|
-
console.log("Edge lengths (meters):");
|
|
1397
|
-
edges.forEach((edge, index) => {
|
|
1398
|
-
console.log(` Edge ${index}: ${edge.distance.toFixed(2)}m`);
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1348
|
+
const { rotationAngle, validPanelPositions } = layoutInfo;
|
|
1401
1349
|
// 패널 크기 계산 (미터 단위)
|
|
1402
1350
|
const panelWidthM = solar_panel_calculator_1.SOLAR_PANEL_SPECS.WIDTH_MM / 1000;
|
|
1403
1351
|
const panelHeightM = solar_panel_calculator_1.SOLAR_PANEL_SPECS.HEIGHT_MM / 1000;
|
|
@@ -1450,8 +1398,6 @@ const GoogleMaps = ({ onPolygonComplete, onPolygonEdit, onPolygonDelete, center,
|
|
|
1450
1398
|
});
|
|
1451
1399
|
panelLayoutOverlaysRef.current.push(panelPolygon);
|
|
1452
1400
|
});
|
|
1453
|
-
console.log(`Drew ${validPanelPositions.length} panels inside polygon at ${((rotationAngle * 180) /
|
|
1454
|
-
Math.PI).toFixed(1)}° rotation (${layoutInfo.orientation} orientation)`);
|
|
1455
1401
|
}
|
|
1456
1402
|
else {
|
|
1457
1403
|
// 기존 fallback 방식 사용
|