sctj-components 1.1.8 → 1.1.10
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/lib/sctj-components.es.js +75 -65
- package/lib/sctj-components.umd.js +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
|
@@ -5399,7 +5399,7 @@ const _sfc_main$8 = {
|
|
|
5399
5399
|
};
|
|
5400
5400
|
}
|
|
5401
5401
|
};
|
|
5402
|
-
const
|
|
5402
|
+
const index_vue_vue_type_style_index_0_scoped_81e99229_lang = "";
|
|
5403
5403
|
const _hoisted_1$6 = {
|
|
5404
5404
|
key: 0,
|
|
5405
5405
|
class: "action-container"
|
|
@@ -5491,8 +5491,8 @@ const _sfc_main$7 = {
|
|
|
5491
5491
|
setup(__props, { expose, emit }) {
|
|
5492
5492
|
const props = __props;
|
|
5493
5493
|
useCssVars((_ctx) => ({
|
|
5494
|
-
"
|
|
5495
|
-
"
|
|
5494
|
+
"2c2353e3": __props.width,
|
|
5495
|
+
"3e782eaa": __props.height
|
|
5496
5496
|
}));
|
|
5497
5497
|
const controlsPositionVars = computed$1(() => {
|
|
5498
5498
|
const position = props.controlsPosition || {};
|
|
@@ -5519,6 +5519,7 @@ const _sfc_main$7 = {
|
|
|
5519
5519
|
const circleInstances = shallowRef([]);
|
|
5520
5520
|
const circleTextInstances = shallowRef([]);
|
|
5521
5521
|
const polygonTextInstances = shallowRef([]);
|
|
5522
|
+
const polylineTextInstances = shallowRef([]);
|
|
5522
5523
|
const typeVisibility = shallowRef(/* @__PURE__ */ new Map());
|
|
5523
5524
|
const overlayGroups = shallowRef(/* @__PURE__ */ new Map());
|
|
5524
5525
|
const isMoreLegend = ref$1(false);
|
|
@@ -5682,10 +5683,8 @@ const _sfc_main$7 = {
|
|
|
5682
5683
|
if (!map.value)
|
|
5683
5684
|
return;
|
|
5684
5685
|
map.value.on("zoomend", () => {
|
|
5685
|
-
updateTextVisibility();
|
|
5686
5686
|
});
|
|
5687
5687
|
map.value.on("moveend", () => {
|
|
5688
|
-
updateTextVisibility();
|
|
5689
5688
|
});
|
|
5690
5689
|
};
|
|
5691
5690
|
const clearMapEvents = () => {
|
|
@@ -5753,6 +5752,7 @@ const _sfc_main$7 = {
|
|
|
5753
5752
|
circleInstances.value = [];
|
|
5754
5753
|
circleTextInstances.value = [];
|
|
5755
5754
|
polygonTextInstances.value = [];
|
|
5755
|
+
polylineTextInstances.value = [];
|
|
5756
5756
|
typeVisibility.value.clear();
|
|
5757
5757
|
});
|
|
5758
5758
|
const initMap = async () => {
|
|
@@ -5909,6 +5909,41 @@ const _sfc_main$7 = {
|
|
|
5909
5909
|
}
|
|
5910
5910
|
return [sumX / path.length, sumY / path.length];
|
|
5911
5911
|
};
|
|
5912
|
+
const haversineDistance = (p1, p2) => {
|
|
5913
|
+
const R = 6371e3;
|
|
5914
|
+
const lat1 = p1[1] * Math.PI / 180;
|
|
5915
|
+
const lat2 = p2[1] * Math.PI / 180;
|
|
5916
|
+
const deltaLat = (p2[1] - p1[1]) * Math.PI / 180;
|
|
5917
|
+
const deltaLng = (p2[0] - p1[0]) * Math.PI / 180;
|
|
5918
|
+
const a = Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(deltaLng / 2) * Math.sin(deltaLng / 2);
|
|
5919
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
5920
|
+
return R * c;
|
|
5921
|
+
};
|
|
5922
|
+
const getPointOnPolylineByPercent = (path, percent = 0.5) => {
|
|
5923
|
+
if (!path || path.length === 0)
|
|
5924
|
+
return null;
|
|
5925
|
+
if (path.length === 1)
|
|
5926
|
+
return [path[0][0], path[0][1]];
|
|
5927
|
+
let totalLength = 0;
|
|
5928
|
+
const lengths = [];
|
|
5929
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
5930
|
+
const length = haversineDistance(path[i], path[i + 1]);
|
|
5931
|
+
lengths.push(length);
|
|
5932
|
+
totalLength += length;
|
|
5933
|
+
}
|
|
5934
|
+
const targetDistance = totalLength * percent;
|
|
5935
|
+
let accumulatedDistance = 0;
|
|
5936
|
+
for (let i = 0; i < lengths.length; i++) {
|
|
5937
|
+
if (targetDistance <= accumulatedDistance + lengths[i]) {
|
|
5938
|
+
const t = (targetDistance - accumulatedDistance) / lengths[i];
|
|
5939
|
+
const lng = path[i][0] + (path[i + 1][0] - path[i][0]) * t;
|
|
5940
|
+
const lat = path[i][1] + (path[i + 1][1] - path[i][1]) * t;
|
|
5941
|
+
return [lng, lat];
|
|
5942
|
+
}
|
|
5943
|
+
accumulatedDistance += lengths[i];
|
|
5944
|
+
}
|
|
5945
|
+
return [path[path.length - 1][0], path[path.length - 1][1]];
|
|
5946
|
+
};
|
|
5912
5947
|
const setLegend = () => {
|
|
5913
5948
|
legend.value = props.legendConfig.filter((item) => item.defaultVisible === void 0 || item.defaultVisible === true).map((item) => item.value);
|
|
5914
5949
|
handleLegendChange(legend.value);
|
|
@@ -5944,7 +5979,8 @@ const _sfc_main$7 = {
|
|
|
5944
5979
|
label && markerInstance.setLabel({
|
|
5945
5980
|
direction: "top",
|
|
5946
5981
|
offset: new AMap.Pixel(0, -5),
|
|
5947
|
-
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div
|
|
5982
|
+
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div>`,
|
|
5983
|
+
zooms: [16, 25]
|
|
5948
5984
|
});
|
|
5949
5985
|
markerInstance.on("click", () => {
|
|
5950
5986
|
emit("overlay-click", { type: "staticMarker", data: marker });
|
|
@@ -5972,11 +6008,13 @@ const _sfc_main$7 = {
|
|
|
5972
6008
|
map: map.value,
|
|
5973
6009
|
title
|
|
5974
6010
|
});
|
|
6011
|
+
console.log("markerInstance", markerInstance);
|
|
5975
6012
|
blink && markerInstance.dom && markerInstance.dom.querySelector(".amap-icon").classList.add("blinking-marker");
|
|
5976
6013
|
label && markerInstance.setLabel({
|
|
5977
6014
|
direction: "top",
|
|
5978
6015
|
offset: new AMap.Pixel(0, -5),
|
|
5979
|
-
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div
|
|
6016
|
+
content: `<div title="${label}" style="${objectToStyleString({ ...state.textLabelDefaultStyle, ...textLabelDefaultStyle })}" class='info'>${label}</div>`,
|
|
6017
|
+
zooms: [16, 25]
|
|
5980
6018
|
});
|
|
5981
6019
|
markerInstance.on("click", () => {
|
|
5982
6020
|
emit("overlay-click", { type: "marker", data: marker });
|
|
@@ -6011,7 +6049,7 @@ const _sfc_main$7 = {
|
|
|
6011
6049
|
},
|
|
6012
6050
|
offset: new AMap.Pixel(0, 0),
|
|
6013
6051
|
anchor: "center",
|
|
6014
|
-
zooms: [
|
|
6052
|
+
zooms: [16, 25]
|
|
6015
6053
|
});
|
|
6016
6054
|
map.value.add(textInstance);
|
|
6017
6055
|
circleTextInstances.value.push({
|
|
@@ -6056,6 +6094,29 @@ const _sfc_main$7 = {
|
|
|
6056
6094
|
path: parsePath(polyline.path),
|
|
6057
6095
|
map: map.value
|
|
6058
6096
|
});
|
|
6097
|
+
let textInstance = null;
|
|
6098
|
+
if (polyline.label) {
|
|
6099
|
+
const center = getPointOnPolylineByPercent(parsePath(polyline.path));
|
|
6100
|
+
textInstance = new AMap.Text({
|
|
6101
|
+
text: polyline.label,
|
|
6102
|
+
position: center,
|
|
6103
|
+
zIndex: 1,
|
|
6104
|
+
style: {
|
|
6105
|
+
...state.textLabelDefaultStyle,
|
|
6106
|
+
...polyline.labelStyle || {}
|
|
6107
|
+
},
|
|
6108
|
+
offset: new AMap.Pixel(0, 0),
|
|
6109
|
+
anchor: "center",
|
|
6110
|
+
zooms: [16, 25]
|
|
6111
|
+
});
|
|
6112
|
+
map.value.add(textInstance);
|
|
6113
|
+
polylineTextInstances.value.push({
|
|
6114
|
+
instance: textInstance,
|
|
6115
|
+
polygonId: parsePath(polyline.path).join("|"),
|
|
6116
|
+
polygonInstance: polylineInstance,
|
|
6117
|
+
path: parsePath(polyline.path)
|
|
6118
|
+
});
|
|
6119
|
+
}
|
|
6059
6120
|
polylineInstance.on("click", () => {
|
|
6060
6121
|
emit("overlay-click", { type: "polyline", data: polyline });
|
|
6061
6122
|
});
|
|
@@ -6105,7 +6166,7 @@ const _sfc_main$7 = {
|
|
|
6105
6166
|
},
|
|
6106
6167
|
offset: new AMap.Pixel(0, 0),
|
|
6107
6168
|
anchor: "center",
|
|
6108
|
-
zooms: [
|
|
6169
|
+
zooms: [16, 25]
|
|
6109
6170
|
});
|
|
6110
6171
|
map.value.add(textInstance);
|
|
6111
6172
|
polygonTextInstances.value.push({
|
|
@@ -6252,6 +6313,10 @@ const _sfc_main$7 = {
|
|
|
6252
6313
|
polyline.setMap(null);
|
|
6253
6314
|
});
|
|
6254
6315
|
polylineInstances.value = [];
|
|
6316
|
+
polylineTextInstances.value.forEach((textObj) => {
|
|
6317
|
+
textObj.instance.setMap(null);
|
|
6318
|
+
});
|
|
6319
|
+
polylineTextInstances.value = [];
|
|
6255
6320
|
};
|
|
6256
6321
|
const clearPolygons = () => {
|
|
6257
6322
|
polygonInstances.value.forEach((polygon) => {
|
|
@@ -6285,61 +6350,6 @@ const _sfc_main$7 = {
|
|
|
6285
6350
|
});
|
|
6286
6351
|
bezierCurveInstances.value = [];
|
|
6287
6352
|
};
|
|
6288
|
-
const updateTextVisibility = () => {
|
|
6289
|
-
if (!map.value)
|
|
6290
|
-
return;
|
|
6291
|
-
circleTextInstances.value.forEach((textObj) => {
|
|
6292
|
-
if (!textObj.circleInstance || !textObj.instance || !textObj.instance.dom)
|
|
6293
|
-
return;
|
|
6294
|
-
const center = textObj.circleInstance.getCenter();
|
|
6295
|
-
const radius = textObj.radius;
|
|
6296
|
-
const pixelRadius = getPixelDistance(center, radius);
|
|
6297
|
-
console.log("pixelRadius", pixelRadius);
|
|
6298
|
-
const labelWidth = textObj.instance.dom.getBoundingClientRect().width;
|
|
6299
|
-
if (labelWidth > pixelRadius * 1.5) {
|
|
6300
|
-
textObj.instance.dom.style.opacity = "0";
|
|
6301
|
-
} else {
|
|
6302
|
-
textObj.instance.dom.style.opacity = "1";
|
|
6303
|
-
}
|
|
6304
|
-
});
|
|
6305
|
-
polygonTextInstances.value.forEach((textObj) => {
|
|
6306
|
-
if (!textObj.polygonInstance || !textObj.instance || !textObj.instance.dom)
|
|
6307
|
-
return;
|
|
6308
|
-
const polygonPixelArea = getPolygonPixelArea(textObj.path);
|
|
6309
|
-
const labelWidth = textObj.instance.dom.offsetWidth;
|
|
6310
|
-
const labelHeight = textObj.instance.dom.offsetHeight;
|
|
6311
|
-
const labelArea = labelWidth * labelHeight;
|
|
6312
|
-
if (labelArea > polygonPixelArea * 0.3) {
|
|
6313
|
-
textObj.instance.dom.style.opacity = "0";
|
|
6314
|
-
} else {
|
|
6315
|
-
textObj.instance.dom.style.opacity = "1";
|
|
6316
|
-
}
|
|
6317
|
-
});
|
|
6318
|
-
};
|
|
6319
|
-
const getPixelDistance = (center, radiusInMeters) => {
|
|
6320
|
-
if (!map.value)
|
|
6321
|
-
return 0;
|
|
6322
|
-
const east = new AMap.LngLat(center.lng, center.lat).offset(radiusInMeters, 90);
|
|
6323
|
-
const centerPx = map.value.lngLatToContainer(center);
|
|
6324
|
-
const eastPx = map.value.lngLatToContainer(east);
|
|
6325
|
-
const dx = eastPx.x - centerPx.x;
|
|
6326
|
-
const dy = eastPx.y - centerPx.y;
|
|
6327
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
6328
|
-
};
|
|
6329
|
-
const getPolygonPixelArea = (path) => {
|
|
6330
|
-
if (!map.value || !path || path.length < 3)
|
|
6331
|
-
return 0;
|
|
6332
|
-
const pixelPath = path.map((point) => {
|
|
6333
|
-
const lngLat = new AMap.LngLat(point[0], point[1]);
|
|
6334
|
-
const pixel = map.value.lngLatToContainer(lngLat);
|
|
6335
|
-
return [pixel.x, pixel.y];
|
|
6336
|
-
});
|
|
6337
|
-
let area = 0;
|
|
6338
|
-
for (let i = 0, j = pixelPath.length - 1; i < pixelPath.length; j = i++) {
|
|
6339
|
-
area += (pixelPath[j][0] + pixelPath[i][0]) * (pixelPath[j][1] - pixelPath[i][1]);
|
|
6340
|
-
}
|
|
6341
|
-
return Math.abs(area / 2);
|
|
6342
|
-
};
|
|
6343
6353
|
expose({
|
|
6344
6354
|
fitView,
|
|
6345
6355
|
updateCenter,
|
|
@@ -6397,7 +6407,7 @@ const _sfc_main$7 = {
|
|
|
6397
6407
|
};
|
|
6398
6408
|
}
|
|
6399
6409
|
};
|
|
6400
|
-
const SCTJMapViewer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-
|
|
6410
|
+
const SCTJMapViewer = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["__scopeId", "data-v-81e99229"]]);
|
|
6401
6411
|
const index_vue_vue_type_style_index_0_scoped_761d2ab4_lang = "";
|
|
6402
6412
|
const _withScopeId$4 = (n) => (pushScopeId("data-v-761d2ab4"), n = n(), popScopeId(), n);
|
|
6403
6413
|
const _hoisted_1$5 = {
|