pukaad-ui-lib 1.280.0 → 1.282.0
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/module.json
CHANGED
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
/>
|
|
35
35
|
|
|
36
36
|
<!-- <InputCheckbox
|
|
37
|
-
name="disableComment"
|
|
37
|
+
name="disableComment"
|
|
38
38
|
label="ไม่อนุญาตให้แสดงความคิดเห็น"
|
|
39
39
|
v-model="form.disableComment"
|
|
40
40
|
/> -->
|
|
@@ -188,7 +188,7 @@ const onSaveDraft = async () => {
|
|
|
188
188
|
const store = tx.objectStore("blogDrafts");
|
|
189
189
|
store.put(draftData);
|
|
190
190
|
tx.oncomplete = () => {
|
|
191
|
-
$toast.success("\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E41\u0E1A\u0E1A\u0E23\u0E48\u0E32\u0E07\
|
|
191
|
+
$toast.success("\u0E1A\u0E31\u0E19\u0E17\u0E36\u0E01\u0E41\u0E1A\u0E1A\u0E23\u0E48\u0E32\u0E07\u0E2A\u0E33\u0E40\u0E23\u0E47\u0E08 !");
|
|
192
192
|
emit("saveDraft", form.value);
|
|
193
193
|
isOpen.value = false;
|
|
194
194
|
};
|
|
@@ -233,7 +233,6 @@ const uploadImage = async (file) => {
|
|
|
233
233
|
throw new Error("\u0E44\u0E21\u0E48\u0E2A\u0E32\u0E21\u0E32\u0E23\u0E16\u0E2A\u0E23\u0E49\u0E32\u0E07 upload URL \u0E44\u0E14\u0E49");
|
|
234
234
|
}
|
|
235
235
|
const item = res.data.items[0];
|
|
236
|
-
console.log("Uploading to S3:", item.upload_url);
|
|
237
236
|
await fetch(item.upload_url, {
|
|
238
237
|
method: "PUT",
|
|
239
238
|
body: file,
|
|
@@ -118,6 +118,29 @@ watch(
|
|
|
118
118
|
drawDebounceTimer = setTimeout(() => drawPolygon(), 80);
|
|
119
119
|
}
|
|
120
120
|
);
|
|
121
|
+
const getPolygonCentroid = (feature) => {
|
|
122
|
+
if (!feature?.geometry) return null;
|
|
123
|
+
const type = feature.geometry.type;
|
|
124
|
+
let coords = null;
|
|
125
|
+
if (type === "Polygon") {
|
|
126
|
+
coords = feature.geometry.coordinates[0];
|
|
127
|
+
} else if (type === "MultiPolygon") {
|
|
128
|
+
let maxLen = 0;
|
|
129
|
+
for (const poly of feature.geometry.coordinates) {
|
|
130
|
+
if (poly[0].length > maxLen) {
|
|
131
|
+
maxLen = poly[0].length;
|
|
132
|
+
coords = poly[0];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (!coords || coords.length === 0) return null;
|
|
137
|
+
let sumLat = 0, sumLng = 0;
|
|
138
|
+
for (const [lng, lat] of coords) {
|
|
139
|
+
sumLat += lat;
|
|
140
|
+
sumLng += lng;
|
|
141
|
+
}
|
|
142
|
+
return { lat: sumLat / coords.length, lng: sumLng / coords.length };
|
|
143
|
+
};
|
|
121
144
|
const drawPolygon = async () => {
|
|
122
145
|
if (!map || !L) return;
|
|
123
146
|
if (polygonLayer) {
|
|
@@ -154,13 +177,14 @@ const drawPolygon = async () => {
|
|
|
154
177
|
}
|
|
155
178
|
}).addTo(map);
|
|
156
179
|
map.flyToBounds(polygonLayer.getBounds(), { padding: [20, 20], duration: 0.5 });
|
|
157
|
-
const center = polygonLayer.getBounds().getCenter();
|
|
180
|
+
const center = getPolygonCentroid(feature) ?? polygonLayer.getBounds().getCenter();
|
|
158
181
|
const divIcon = L.divIcon({
|
|
159
182
|
html: mapPinSvg,
|
|
160
183
|
className: "",
|
|
161
184
|
// Remove default leaflet background
|
|
162
185
|
iconSize: [32, 32],
|
|
163
|
-
iconAnchor: [16,
|
|
186
|
+
iconAnchor: [16, 16]
|
|
187
|
+
// center of icon aligns with coordinate
|
|
164
188
|
});
|
|
165
189
|
marker = L.marker(center, {
|
|
166
190
|
icon: divIcon
|
package/package.json
CHANGED
|
File without changes
|